neography 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS +5 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +46 -41
- data/lib/neography/rest.rb +41 -30
- data/lib/neography/version.rb +1 -1
- data/spec/integration/rest_index_spec.rb +6 -9
- data/spec/integration/rest_node_spec.rb +52 -69
- data/spec/integration/rest_path_spec.rb +65 -112
- data/spec/integration/rest_relationship_spec.rb +85 -151
- data/spec/integration/rest_traverse_spec.rb +89 -170
- metadata +4 -3
@@ -3,52 +3,35 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
|
3
3
|
describe Neography::Rest do
|
4
4
|
before(:each) do
|
5
5
|
@neo = Neography::Rest.new
|
6
|
+
@new_node1 = @neo.create_node("age" => 31, "name" => "Max")
|
7
|
+
@new_node2 = @neo.create_node("age" => 30, "name" => "Helene")
|
8
|
+
@new_node3 = @neo.create_node("age" => 17, "name" => "Alex")
|
9
|
+
@new_node4 = @neo.create_node("age" => 24, "name" => "Eric")
|
10
|
+
@new_node5 = @neo.create_node("age" => 32, "name" => "Leslie")
|
6
11
|
end
|
7
12
|
|
8
13
|
describe "traverse" do
|
9
14
|
it "can traverse the graph and return nodes" do
|
10
|
-
new_node1
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
new_node3
|
15
|
-
|
16
|
-
new_node4 = @neo.create_node
|
17
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
18
|
-
new_node5 = @neo.create_node
|
19
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
20
|
-
@neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
21
|
-
@neo.create_relationship("friends", new_node2[:id], new_node3[:id])
|
22
|
-
@neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
23
|
-
@neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
24
|
-
@neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
25
|
-
nodes = @neo.traverse(new_node1[:id], "nodes", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
15
|
+
@neo.create_relationship("friends", @new_node1, @new_node2)
|
16
|
+
@neo.create_relationship("friends", @new_node2, @new_node3)
|
17
|
+
@neo.create_relationship("friends", @new_node3, @new_node4)
|
18
|
+
@neo.create_relationship("friends", @new_node4, @new_node5)
|
19
|
+
@neo.create_relationship("friends", @new_node3, @new_node5)
|
20
|
+
nodes = @neo.traverse(@new_node1, "nodes", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
26
21
|
nodes.should_not be_nil
|
27
|
-
nodes[0]["self"].should == new_node2["self"]
|
28
|
-
nodes[1]["self"].should == new_node3["self"]
|
29
|
-
nodes[2]["self"].should == new_node4["self"]
|
30
|
-
nodes[3]["self"].should == new_node5["self"]
|
22
|
+
nodes[0]["self"].should == @new_node2["self"]
|
23
|
+
nodes[1]["self"].should == @new_node3["self"]
|
24
|
+
nodes[2]["self"].should == @new_node4["self"]
|
25
|
+
nodes[3]["self"].should == @new_node5["self"]
|
31
26
|
end
|
32
|
-
|
33
27
|
it "can traverse the graph and return relationships" do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
42
|
-
new_node5 = @neo.create_node
|
43
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
44
|
-
|
45
|
-
new_relationship1= @neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
46
|
-
new_relationship2= @neo.create_relationship("friends", new_node2[:id], new_node3[:id])
|
47
|
-
new_relationship3= @neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
48
|
-
new_relationship4= @neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
49
|
-
new_relationship5= @neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
50
|
-
|
51
|
-
relationships = @neo.traverse(new_node1[:id], "relationships", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
28
|
+
new_relationship1= @neo.create_relationship("friends", @new_node1, @new_node2)
|
29
|
+
new_relationship2= @neo.create_relationship("friends", @new_node2, @new_node3)
|
30
|
+
new_relationship3= @neo.create_relationship("friends", @new_node3, @new_node4)
|
31
|
+
new_relationship4= @neo.create_relationship("friends", @new_node4, @new_node5)
|
32
|
+
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
33
|
+
|
34
|
+
relationships = @neo.traverse(@new_node1, "relationships", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
52
35
|
relationships.should_not be_nil
|
53
36
|
|
54
37
|
relationships[0]["self"].should == new_relationship1["self"]
|
@@ -58,173 +41,109 @@ describe Neography::Rest do
|
|
58
41
|
end
|
59
42
|
|
60
43
|
it "can traverse the graph and return paths" do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
69
|
-
new_node5 = @neo.create_node
|
70
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
71
|
-
|
72
|
-
new_relationship1= @neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
73
|
-
new_relationship2= @neo.create_relationship("friends", new_node2[:id], new_node3[:id])
|
74
|
-
new_relationship3= @neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
75
|
-
new_relationship4= @neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
76
|
-
new_relationship5= @neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
77
|
-
|
78
|
-
paths = @neo.traverse(new_node1[:id], "paths", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
44
|
+
new_relationship1= @neo.create_relationship("friends", @new_node1, @new_node2)
|
45
|
+
new_relationship2= @neo.create_relationship("friends", @new_node2, @new_node3)
|
46
|
+
new_relationship3= @neo.create_relationship("friends", @new_node3, @new_node4)
|
47
|
+
new_relationship4= @neo.create_relationship("friends", @new_node4, @new_node5)
|
48
|
+
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
49
|
+
|
50
|
+
paths = @neo.traverse(@new_node1, "paths", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
79
51
|
paths.should_not be_nil
|
80
52
|
|
81
|
-
paths[0]["nodes"].should == [new_node1["self"], new_node2["self"]]
|
82
|
-
paths[1]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"]]
|
83
|
-
paths[2]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node4["self"]]
|
84
|
-
paths[3]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node4["self"], new_node5["self"]]
|
53
|
+
paths[0]["nodes"].should == [@new_node1["self"], @new_node2["self"]]
|
54
|
+
paths[1]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"]]
|
55
|
+
paths[2]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]]
|
56
|
+
paths[3]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"], @new_node5["self"]]
|
85
57
|
end
|
86
58
|
|
87
59
|
it "can traverse the graph up to a certain depth" do
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
96
|
-
new_node5 = @neo.create_node
|
97
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
98
|
-
|
99
|
-
new_relationship1= @neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
100
|
-
new_relationship2= @neo.create_relationship("friends", new_node2[:id], new_node3[:id])
|
101
|
-
new_relationship3= @neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
102
|
-
new_relationship4= @neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
103
|
-
new_relationship5= @neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
104
|
-
|
105
|
-
paths = @neo.traverse(new_node1[:id], "paths", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 3} )
|
60
|
+
new_relationship1= @neo.create_relationship("friends", @new_node1, @new_node2)
|
61
|
+
new_relationship2= @neo.create_relationship("friends", @new_node2, @new_node3)
|
62
|
+
new_relationship3= @neo.create_relationship("friends", @new_node3, @new_node4)
|
63
|
+
new_relationship4= @neo.create_relationship("friends", @new_node4, @new_node5)
|
64
|
+
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
65
|
+
|
66
|
+
paths = @neo.traverse(@new_node1, "paths", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 3} )
|
106
67
|
paths.should_not be_nil
|
107
68
|
|
108
|
-
paths[0]["nodes"].should == [new_node1["self"], new_node2["self"]]
|
109
|
-
paths[1]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"]]
|
110
|
-
paths[2]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node4["self"]]
|
111
|
-
paths[3]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node5["self"]]
|
69
|
+
paths[0]["nodes"].should == [@new_node1["self"], @new_node2["self"]]
|
70
|
+
paths[1]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"]]
|
71
|
+
paths[2]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]]
|
72
|
+
paths[3]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node5["self"]]
|
112
73
|
end
|
113
74
|
|
114
75
|
it "can traverse the graph in a certain order" do
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
123
|
-
new_node5 = @neo.create_node
|
124
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
125
|
-
|
126
|
-
new_relationship1= @neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
127
|
-
new_relationship2= @neo.create_relationship("friends", new_node2[:id], new_node3[:id])
|
128
|
-
new_relationship3= @neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
129
|
-
new_relationship4= @neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
130
|
-
new_relationship5= @neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
131
|
-
|
132
|
-
paths = @neo.traverse(new_node1[:id], "paths", {"order" => "breadth first", "relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
76
|
+
new_relationship1= @neo.create_relationship("friends", @new_node1, @new_node2)
|
77
|
+
new_relationship2= @neo.create_relationship("friends", @new_node2, @new_node3)
|
78
|
+
new_relationship3= @neo.create_relationship("friends", @new_node3, @new_node4)
|
79
|
+
new_relationship4= @neo.create_relationship("friends", @new_node4, @new_node5)
|
80
|
+
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
81
|
+
|
82
|
+
paths = @neo.traverse(@new_node1, "paths", {"order" => "breadth first", "relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
133
83
|
paths.should_not be_nil
|
134
84
|
|
135
|
-
paths[0]["nodes"].should == [new_node1["self"], new_node2["self"]]
|
136
|
-
paths[1]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"]]
|
137
|
-
paths[2]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node4["self"]]
|
138
|
-
paths[3]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node5["self"]]
|
85
|
+
paths[0]["nodes"].should == [@new_node1["self"], @new_node2["self"]]
|
86
|
+
paths[1]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"]]
|
87
|
+
paths[2]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]]
|
88
|
+
paths[3]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node5["self"]]
|
139
89
|
end
|
140
90
|
|
141
91
|
it "can traverse the graph with a specific uniqueness" do
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
152
|
-
|
153
|
-
new_relationship1= @neo.create_relationship("roommates", new_node1[:id], new_node2[:id])
|
154
|
-
new_relationship2= @neo.create_relationship("roommates", new_node2[:id], new_node3[:id])
|
155
|
-
new_relationship1= @neo.create_relationship("friends", new_node3[:id], new_node2[:id])
|
156
|
-
new_relationship2= @neo.create_relationship("friends", new_node2[:id], new_node5[:id])
|
157
|
-
new_relationship3= @neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
158
|
-
new_relationship4= @neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
159
|
-
new_relationship5= @neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
160
|
-
|
161
|
-
paths = @neo.traverse(new_node1[:id], "paths", {"order" => "breadth first", "uniqueness" => "node global", "relationships" => [{"type"=> "roommates", "direction" => "all"},{"type"=> "friends", "direction" => "out"}], "depth" => 4} )
|
92
|
+
new_relationship1= @neo.create_relationship("roommates", @new_node1, @new_node2)
|
93
|
+
new_relationship2= @neo.create_relationship("roommates", @new_node2, @new_node3)
|
94
|
+
new_relationship1= @neo.create_relationship("friends", @new_node3, @new_node2)
|
95
|
+
new_relationship2= @neo.create_relationship("friends", @new_node2, @new_node5)
|
96
|
+
new_relationship3= @neo.create_relationship("friends", @new_node3, @new_node4)
|
97
|
+
new_relationship4= @neo.create_relationship("friends", @new_node4, @new_node5)
|
98
|
+
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
99
|
+
|
100
|
+
paths = @neo.traverse(@new_node1, "paths", {"order" => "breadth first", "uniqueness" => "node global", "relationships" => [{"type"=> "roommates", "direction" => "all"},{"type"=> "friends", "direction" => "out"}], "depth" => 4} )
|
162
101
|
paths.should_not be_nil
|
163
102
|
|
164
|
-
paths[0]["nodes"].should == [new_node1["self"], new_node2["self"]]
|
165
|
-
paths[1]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"]]
|
166
|
-
paths[2]["nodes"].should == [new_node1["self"], new_node2["self"], new_node5["self"]]
|
167
|
-
paths[3]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node4["self"]]
|
103
|
+
paths[0]["nodes"].should == [@new_node1["self"], @new_node2["self"]]
|
104
|
+
paths[1]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"]]
|
105
|
+
paths[2]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node5["self"]]
|
106
|
+
paths[3]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]]
|
168
107
|
end
|
169
108
|
|
170
109
|
it "can traverse the graph with a prune evaluator" do
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
179
|
-
new_node5 = @neo.create_node("age" => 32, "name" => "Leslie")
|
180
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
181
|
-
|
182
|
-
new_relationship1= @neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
183
|
-
new_relationship2= @neo.create_relationship("friends", new_node2[:id], new_node3[:id])
|
184
|
-
new_relationship3= @neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
185
|
-
new_relationship4= @neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
186
|
-
new_relationship5= @neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
187
|
-
|
188
|
-
paths = @neo.traverse(new_node1[:id],
|
110
|
+
new_relationship1= @neo.create_relationship("friends", @new_node1, @new_node2)
|
111
|
+
new_relationship2= @neo.create_relationship("friends", @new_node2, @new_node3)
|
112
|
+
new_relationship3= @neo.create_relationship("friends", @new_node3, @new_node4)
|
113
|
+
new_relationship4= @neo.create_relationship("friends", @new_node4, @new_node5)
|
114
|
+
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
115
|
+
|
116
|
+
paths = @neo.traverse(@new_node1,
|
189
117
|
"paths",
|
190
118
|
{"relationships" => {"type"=> "friends", "direction" => "out"},
|
191
119
|
"depth" => 3,
|
192
120
|
"prune evaluator" => {"language" => "javascript", "body" => "position.endNode().getProperty('age') < 21;"
|
193
121
|
}} )
|
194
122
|
paths.should_not be_nil
|
195
|
-
paths[0]["nodes"].should == [new_node1["self"], new_node2["self"]]
|
196
|
-
paths[1]["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"]]
|
123
|
+
paths[0]["nodes"].should == [@new_node1["self"], @new_node2["self"]]
|
124
|
+
paths[1]["nodes"].should == [@new_node1["self"], @new_node2["self"], @new_node3["self"]]
|
197
125
|
paths[2].should be_nil
|
198
126
|
end
|
199
127
|
|
200
128
|
it "can traverse the graph with a return filter" do
|
201
|
-
new_node1
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
new_node3
|
206
|
-
|
207
|
-
new_node4 = @neo.create_node
|
208
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
209
|
-
new_node5 = @neo.create_node
|
210
|
-
new_node5[:id] = new_node5["self"].split('/').last
|
211
|
-
@neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
212
|
-
@neo.create_relationship("friends", new_node2[:id], new_node3[:id])
|
213
|
-
@neo.create_relationship("friends", new_node3[:id], new_node4[:id])
|
214
|
-
@neo.create_relationship("friends", new_node4[:id], new_node5[:id])
|
215
|
-
@neo.create_relationship("friends", new_node3[:id], new_node5[:id])
|
216
|
-
nodes = @neo.traverse(new_node1[:id], "nodes", {"relationships" => {"type"=> "friends", "direction" => "out"},
|
129
|
+
@neo.create_relationship("friends", @new_node1, @new_node2)
|
130
|
+
@neo.create_relationship("friends", @new_node2, @new_node3)
|
131
|
+
@neo.create_relationship("friends", @new_node3, @new_node4)
|
132
|
+
@neo.create_relationship("friends", @new_node4, @new_node5)
|
133
|
+
@neo.create_relationship("friends", @new_node3, @new_node5)
|
134
|
+
nodes = @neo.traverse(@new_node1, "nodes", {"relationships" => {"type"=> "friends", "direction" => "out"},
|
217
135
|
"return filter" => {"language" => "builtin", "name" => "all"},
|
218
136
|
"depth" => 4} )
|
219
137
|
nodes.should_not be_nil
|
220
|
-
nodes[0]["self"].should == new_node1["self"]
|
221
|
-
nodes[1]["self"].should == new_node2["self"]
|
222
|
-
nodes[2]["self"].should == new_node3["self"]
|
223
|
-
nodes[3]["self"].should == new_node4["self"]
|
224
|
-
nodes[4]["self"].should == new_node5["self"]
|
138
|
+
nodes[0]["self"].should == @new_node1["self"]
|
139
|
+
nodes[1]["self"].should == @new_node2["self"]
|
140
|
+
nodes[2]["self"].should == @new_node3["self"]
|
141
|
+
nodes[3]["self"].should == @new_node4["self"]
|
142
|
+
nodes[4]["self"].should == @new_node5["self"]
|
225
143
|
end
|
226
144
|
|
227
145
|
|
146
|
+
|
228
147
|
end
|
229
148
|
|
230
149
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Max De Marzi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-21 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -102,6 +102,7 @@ extra_rdoc_files: []
|
|
102
102
|
|
103
103
|
files:
|
104
104
|
- .gitignore
|
105
|
+
- CONTRIBUTORS
|
105
106
|
- Gemfile
|
106
107
|
- Gemfile.lock
|
107
108
|
- LICENSE
|