| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| lib/dagnabit/link/class_methods.rb | 43 | 18 | 100.00%
|
100.00%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 module Dagnabit |
2 module Link |
3 # |
4 # Handy class methods for creating and querying paths. |
5 # |
6 module ClassMethods |
7 # |
8 # Constructs a new edge. The direction of the edge runs from +from+ to +to+. |
9 # |
10 def build_edge(from, to, attributes = {}) |
11 new(attributes.merge(:ancestor => from, :descendant => to)) |
12 end |
13 |
14 # |
15 # Like +build_edge+, but saves the edge after it is instantiated. |
16 # Returns true if the endpoints could be connected, false otherwise. |
17 # |
18 # See Dagnabit::Link::Validations for more information on built-in link |
19 # validations. |
20 # |
21 def connect(from, to, attributes = {}) |
22 build_edge(from, to, attributes).save |
23 end |
24 |
25 # |
26 # Returns true if there is a path from +a+ to +b+, false otherwise. |
27 # |
28 def path?(a, b) |
29 paths(a, b).count > 0 |
30 end |
31 |
32 # |
33 # Returns all paths from +a+ to +b+. |
34 # |
35 # These paths are returned as transitive closure links, which aren't |
36 # guaranteed to have the same methods as your link class. |
37 # |
38 def paths(a, b) |
39 transitive_closure_class.linking(a, b) |
40 end |
41 end |
42 end |
43 end |
Generated on Tue Dec 08 04:06:14 -0600 2009 with rcov 0.9.6