pacer 0.9.1.1-java → 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -1
- data/.gitignore +4 -0
- data/.rspec +1 -1
- data/Gemfile-dev +33 -0
- data/Gemfile-release +4 -0
- data/README.md +27 -9
- data/Rakefile +26 -8
- data/bin/autotest +1 -1
- data/lib/pacer/blueprints/multi_graph.rb +7 -19
- data/lib/pacer/blueprints/ruby_graph.rb +77 -52
- data/lib/pacer/blueprints/tg.rb +6 -93
- data/lib/pacer/blueprints.rb +0 -1
- data/lib/pacer/core/graph/edges_route.rb +10 -12
- data/lib/pacer/core/graph/element_route.rb +14 -21
- data/lib/pacer/core/graph/graph_index_route.rb +12 -8
- data/lib/pacer/core/graph/graph_route.rb +2 -5
- data/lib/pacer/core/graph/mixed_route.rb +3 -5
- data/lib/pacer/core/graph/vertices_route.rb +26 -27
- data/lib/pacer/core/route.rb +35 -66
- data/lib/pacer/exceptions.rb +13 -6
- data/lib/pacer/extensions/block_filter_element.rb +0 -5
- data/lib/pacer/filter/collection_filter.rb +9 -2
- data/lib/pacer/filter/empty_filter.rb +12 -3
- data/lib/pacer/filter/future_filter.rb +5 -5
- data/lib/pacer/filter/loop_filter.rb +7 -13
- data/lib/pacer/filter/object_filter.rb +10 -16
- data/lib/pacer/filter/property_filter/filters.rb +134 -93
- data/lib/pacer/filter/property_filter.rb +22 -19
- data/lib/pacer/filter/where_filter/node_visitor.rb +47 -26
- data/lib/pacer/filter/where_filter.rb +24 -3
- data/lib/pacer/function_resolver.rb +7 -2
- data/lib/pacer/graph/graph_ml.rb +39 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +107 -175
- data/lib/pacer/graph/pacer_graph.rb +438 -0
- data/lib/pacer/graph/simple_encoder.rb +20 -0
- data/lib/pacer/graph/yaml_encoder.rb +81 -0
- data/lib/pacer/graph.rb +8 -10
- data/lib/pacer/pipe/blackbox_pipeline.rb +11 -4
- data/lib/pacer/pipe/block_filter_pipe.rb +5 -22
- data/lib/pacer/pipe/cross_product_transform_pipe.rb +5 -7
- data/lib/pacer/pipe/edges_pipe.rb +22 -0
- data/lib/pacer/pipe/enumerable_pipe.rb +3 -9
- data/lib/pacer/pipe/expandable_pipe.rb +2 -14
- data/lib/pacer/pipe/id_collection_filter_pipe.rb +2 -8
- data/lib/pacer/pipe/is_empty_pipe.rb +5 -12
- data/lib/pacer/pipe/is_unique_pipe.rb +3 -13
- data/lib/pacer/pipe/label_collection_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/label_prefix_pipe.rb +0 -6
- data/lib/pacer/pipe/loop_pipe.rb +27 -25
- data/lib/pacer/pipe/never_pipe.rb +1 -1
- data/lib/pacer/pipe/path_wrapping_pipe.rb +40 -0
- data/lib/pacer/pipe/process_pipe.rb +2 -20
- data/lib/pacer/pipe/property_comparison_pipe.rb +0 -6
- data/lib/pacer/pipe/ruby_pipe.rb +10 -3
- data/lib/pacer/pipe/simple_visitor_pipe.rb +12 -11
- data/lib/pacer/pipe/stream_sort_pipe.rb +1 -7
- data/lib/pacer/pipe/stream_uniq_pipe.rb +0 -6
- data/lib/pacer/pipe/type_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/unary_transform_pipe.rb +6 -8
- data/lib/pacer/pipe/unwrapping_pipe.rb +13 -0
- data/lib/pacer/pipe/vertices_pipe.rb +22 -0
- data/lib/pacer/pipe/visitor_pipe.rb +3 -7
- data/lib/pacer/pipe/wrapping_pipe.rb +37 -0
- data/lib/pacer/pipes.rb +17 -12
- data/lib/pacer/route/mixin/bulk_operations.rb +8 -9
- data/lib/pacer/route/mixin/route_operations.rb +17 -11
- data/lib/pacer/route/mixins.rb +0 -1
- data/lib/pacer/route.rb +198 -121
- data/lib/pacer/side_effect/aggregate.rb +22 -2
- data/lib/pacer/side_effect/as.rb +73 -0
- data/lib/pacer/side_effect/group_count.rb +0 -3
- data/lib/pacer/side_effect/is_unique.rb +7 -6
- data/lib/pacer/side_effect.rb +1 -1
- data/lib/pacer/support/enumerable.rb +14 -12
- data/lib/pacer/support/nil_class.rb +5 -0
- data/lib/pacer/support/proc.rb +2 -2
- data/lib/pacer/support.rb +1 -1
- data/lib/pacer/transform/cap.rb +1 -1
- data/lib/pacer/transform/has_count_cap.rb +1 -1
- data/lib/pacer/transform/join.rb +20 -16
- data/lib/pacer/transform/map.rb +6 -2
- data/lib/pacer/transform/path.rb +44 -20
- data/lib/pacer/transform/sort_section.rb +58 -51
- data/lib/pacer/utils/tsort.rb +7 -2
- data/lib/pacer/utils.rb +0 -1
- data/lib/pacer/version.rb +4 -3
- data/lib/pacer/visitors/section.rb +42 -0
- data/lib/pacer/visitors/visits_section.rb +32 -0
- data/lib/pacer/visitors.rb +7 -0
- data/lib/pacer/wrappers/edge_wrapper.rb +164 -11
- data/lib/pacer/wrappers/element_wrapper.rb +133 -8
- data/lib/pacer/wrappers/index_wrapper.rb +47 -0
- data/lib/pacer/wrappers/vertex_wrapper.rb +175 -12
- data/lib/pacer/wrappers/wrapper_selector.rb +40 -0
- data/lib/pacer/wrappers/wrapping_pipe_function.rb +90 -0
- data/lib/pacer/wrappers.rb +3 -1
- data/lib/pacer-1.0.0-standalone.jar +0 -0
- data/lib/pacer.rb +13 -47
- data/pacer.gemspec +0 -8
- data/pom.xml +10 -3
- data/spec/pacer/blueprints/dex_spec.rb +12 -26
- data/spec/pacer/blueprints/neo4j_spec.rb +14 -28
- data/spec/pacer/blueprints/tg_spec.rb +6 -54
- data/spec/pacer/core/graph/edges_route_spec.rb +1 -1
- data/spec/pacer/core/graph/element_route_spec.rb +2 -2
- data/spec/pacer/core/graph/graph_route_spec.rb +2 -2
- data/spec/pacer/core/graph/vertices_route_spec.rb +10 -3
- data/spec/pacer/core/route_spec.rb +35 -58
- data/spec/pacer/filter/empty_filter_spec.rb +5 -6
- data/spec/pacer/filter/future_filter_spec.rb +8 -8
- data/spec/pacer/filter/loop_filter_spec.rb +120 -6
- data/spec/pacer/filter/object_filter_spec.rb +15 -0
- data/spec/pacer/filter/property_filter/filters_spec.rb +169 -0
- data/spec/pacer/filter/property_filter_spec.rb +15 -12
- data/spec/pacer/filter/uniq_filter_spec.rb +1 -1
- data/spec/pacer/filter/where_filter_spec.rb +55 -7
- data/spec/pacer/graph/{graph_mixin_spec.rb → pacer_graph_spec.rb} +114 -185
- data/spec/pacer/route/mixin/base_spec.rb +36 -35
- data/spec/pacer/route/mixin/route_operations_spec.rb +4 -46
- data/spec/pacer/side_effect/as_spec.rb +34 -0
- data/spec/pacer/support/enumerable_spec.rb +6 -6
- data/spec/pacer/transform/join_spec.rb +7 -5
- data/spec/pacer/transform/map_spec.rb +55 -0
- data/spec/pacer/transform/path_spec.rb +30 -15
- data/spec/pacer/transform/process_spec.rb +42 -0
- data/spec/pacer/transform/sort_section_spec.rb +82 -0
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +122 -2
- data/spec/pacer/wrapper/element_wrapper_spec.rb +289 -3
- data/spec/pacer/wrapper/vertex_wrapper_spec.rb +289 -2
- data/spec/spec_helper.rb +16 -7
- data/spec/support/graph_runner.rb +80 -29
- data/tags +1165 -0
- metadata +46 -107
- data/.rvmrc +0 -0
- data/lib/pacer/blueprints/extensions.rb +0 -77
- data/lib/pacer/graph/edge_mixin.rb +0 -127
- data/lib/pacer/graph/element_mixin.rb +0 -202
- data/lib/pacer/graph/graph_indices_mixin.rb +0 -93
- data/lib/pacer/graph/graph_mixin.rb +0 -361
- data/lib/pacer/graph/index_mixin.rb +0 -30
- data/lib/pacer/graph/vertex_mixin.rb +0 -119
- data/lib/pacer/pipe/map_pipe.rb +0 -36
- data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +0 -26
- data/lib/pacer/route/mixin/variable_route_module.rb +0 -26
- data/lib/pacer/side_effect/section.rb +0 -25
- data/lib/pacer/support/iterator_mixins.rb +0 -110
- data/lib/pacer/wrappers/new_element.rb +0 -106
- data/lib/pacer-0.9.1.1-standalone.jar +0 -0
- data/spec/pacer/graph/edge_mixin_spec.rb +0 -116
- data/spec/pacer/graph/element_mixin_spec.rb +0 -297
- data/spec/pacer/graph/index_mixin_spec.rb +0 -0
- data/spec/pacer/graph/vertex_mixin_spec.rb +0 -192
@@ -15,7 +15,11 @@ Run.all :read_only do
|
|
15
15
|
its(:extensions) { should == v_exts }
|
16
16
|
|
17
17
|
describe 'instance' do
|
18
|
-
subject
|
18
|
+
subject do
|
19
|
+
v = v_wrapper_class.new pacer.element
|
20
|
+
v.graph = graph
|
21
|
+
v
|
22
|
+
end
|
19
23
|
it { should_not be_nil }
|
20
24
|
its(:element) { should_not be_nil }
|
21
25
|
it { should == pacer }
|
@@ -24,10 +28,293 @@ Run.all :read_only do
|
|
24
28
|
its(:extensions) { should == v_exts }
|
25
29
|
|
26
30
|
describe 'with more extensions added' do
|
27
|
-
subject { v_wrapper_class.new(pacer).add_extensions([Pacer::Utils::TSort]) }
|
31
|
+
subject { v_wrapper_class.new(pacer.element).add_extensions([Pacer::Utils::TSort]) }
|
28
32
|
its(:class) { should_not == v_wrapper_class }
|
29
33
|
its(:extensions) { should == v_exts + [Pacer::Utils::TSort] }
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
38
|
+
|
39
|
+
module VertexWrapperSpec
|
40
|
+
module Project
|
41
|
+
def self.route_conditions
|
42
|
+
{ :type => 'project' }
|
43
|
+
end
|
44
|
+
|
45
|
+
module Vertex
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module IsRuby
|
50
|
+
def self.route_conditions
|
51
|
+
{ :language => 'ruby' }
|
52
|
+
end
|
53
|
+
|
54
|
+
module Vertex
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
shared_examples_for Pacer::Wrappers::VertexWrapper do
|
60
|
+
use_simple_graph_data
|
61
|
+
|
62
|
+
describe '#v' do
|
63
|
+
subject { v0.v }
|
64
|
+
it { should be_a_vertices_route }
|
65
|
+
its(:element_type) { should == :vertex }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#add_extensions' do
|
69
|
+
context 'no extensions' do
|
70
|
+
subject { v0.add_extensions([]) }
|
71
|
+
its('extensions.to_a') { should == [] }
|
72
|
+
its(:class) { should == Pacer::Wrappers::VertexWrapper }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with extensions' do
|
76
|
+
subject { v0.add_extensions([Tackle::SimpleMixin]) }
|
77
|
+
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
78
|
+
it { should be_a(Pacer::Wrappers::ElementWrapper) }
|
79
|
+
it { should be_a(Pacer::Wrappers::VertexWrapper) }
|
80
|
+
it { should_not be_a(Pacer::Wrappers::EdgeWrapper) }
|
81
|
+
|
82
|
+
describe '#v' do
|
83
|
+
subject { v0.add_extensions([Tackle::SimpleMixin]).v }
|
84
|
+
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
85
|
+
it { should be_a_vertices_route }
|
86
|
+
it { should be_a(Tackle::SimpleMixin::Route) }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#as?' do
|
92
|
+
let(:v) { graph.create_vertex type: 'project' }
|
93
|
+
context 'Project' do
|
94
|
+
subject { v.as?(VertexWrapperSpec::Project) }
|
95
|
+
it { should be_true }
|
96
|
+
end
|
97
|
+
context 'IsRuby' do
|
98
|
+
subject { v.as?(VertexWrapperSpec::IsRuby) }
|
99
|
+
it { should_not be_true }
|
100
|
+
end
|
101
|
+
context 'Project, IsRuby' do
|
102
|
+
subject { v.as?(VertexWrapperSpec::Project, VertexWrapperSpec::IsRuby) }
|
103
|
+
it { should_not be_true }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#as' do
|
108
|
+
context 'vertex is a Project' do
|
109
|
+
let(:v) { graph.create_vertex type: 'project' }
|
110
|
+
|
111
|
+
it 'should yield a Project' do
|
112
|
+
yielded = false
|
113
|
+
v.as(VertexWrapperSpec::Project) do |v2|
|
114
|
+
yielded = true
|
115
|
+
v2.should == v
|
116
|
+
v2.extensions.should include VertexWrapperSpec::Project
|
117
|
+
v2.should be_a VertexWrapperSpec::Project::Vertex
|
118
|
+
end
|
119
|
+
yielded.should be_true
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should not yield a IsRuby' do
|
123
|
+
yielded = false
|
124
|
+
v.as(VertexWrapperSpec::IsRuby) do |v2|
|
125
|
+
yielded = true
|
126
|
+
end
|
127
|
+
yielded.should be_false
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#only_as' do
|
133
|
+
context 'able' do
|
134
|
+
subject { graph.create_vertex VertexWrapperSpec::IsRuby, type: 'project', language: 'ruby' }
|
135
|
+
|
136
|
+
its(:extensions) { should include VertexWrapperSpec::IsRuby }
|
137
|
+
|
138
|
+
it 'should yield a Project' do
|
139
|
+
yielded = false
|
140
|
+
subject.only_as(VertexWrapperSpec::Project) do |v2|
|
141
|
+
yielded = true
|
142
|
+
v2.should == subject
|
143
|
+
v2.extensions.should == [VertexWrapperSpec::Project]
|
144
|
+
v2.should be_a VertexWrapperSpec::Project::Vertex
|
145
|
+
end
|
146
|
+
yielded.should be_true
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'unable' do
|
151
|
+
subject { graph.create_vertex VertexWrapperSpec::IsRuby, language: 'ruby' }
|
152
|
+
|
153
|
+
it 'should not yield a Project' do
|
154
|
+
yielded = false
|
155
|
+
subject.only_as(VertexWrapperSpec::Project) do |v2|
|
156
|
+
yielded = true
|
157
|
+
end
|
158
|
+
yielded.should be_false
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#delete!' do
|
164
|
+
before do
|
165
|
+
@vertex_id = v0.element_id
|
166
|
+
v0.delete!
|
167
|
+
c = example.metadata[:graph_commit]
|
168
|
+
c.call if c
|
169
|
+
end
|
170
|
+
it 'should be removed' do
|
171
|
+
graph.vertex(@vertex_id).should be_nil
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
contexts(
|
176
|
+
'into new tg' => proc {
|
177
|
+
let(:dest) { Pacer.tg }
|
178
|
+
},
|
179
|
+
'into graph2' => proc {
|
180
|
+
before { pending 'support temporary hash indices for clone/copy' unless graph.features.supportsIndices }
|
181
|
+
let(:dest) { graph2 }
|
182
|
+
}) do
|
183
|
+
describe '#clone_into', :transactions => false do
|
184
|
+
subject { v0.clone_into(dest) }
|
185
|
+
its(:properties) { should == { 'name' => 'eliza' } }
|
186
|
+
its(:graph) { should equal(dest) }
|
187
|
+
its('element_id.to_s') { should == v0.element_id.to_s unless graph.features.ignoresSuppliedIds }
|
188
|
+
end
|
189
|
+
|
190
|
+
describe '#copy_into', :transaction => false do
|
191
|
+
subject { v1.copy_into(dest) }
|
192
|
+
its(:properties) { should == { 'name' => 'darrick' } }
|
193
|
+
its(:graph) { should equal(dest) }
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
subject { v0 }
|
198
|
+
its(:graph) { should equal(graph) }
|
199
|
+
its(:display_name) { should be_nil }
|
200
|
+
its(:inspect) { should =~ /#<[VM]\[#{v0.element_id}\]>/ }
|
201
|
+
context 'with label proc' do
|
202
|
+
before do
|
203
|
+
graph.vertex_name = proc { |e| "some name" }
|
204
|
+
end
|
205
|
+
its(:display_name) { should == "some name" }
|
206
|
+
its(:inspect) { should =~ /#<[VM]\[#{ v0.element_id }\] some name>/ }
|
207
|
+
end
|
208
|
+
it { should_not == v1 }
|
209
|
+
it { should == v0 }
|
210
|
+
context 'edge with same element id', :transactions => false do
|
211
|
+
it { should_not == e0 }
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'with more data' do
|
215
|
+
let(:from_v) { graph.create_vertex }
|
216
|
+
let(:to_v) { graph.create_vertex }
|
217
|
+
|
218
|
+
before do
|
219
|
+
%w[ a a a b b c ].each do |label|
|
220
|
+
v = graph.create_vertex
|
221
|
+
graph.create_edge nil, from_v, v, label
|
222
|
+
graph.create_edge nil, v, to_v, label
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe '#in_edges' do
|
227
|
+
specify 'to_v should have 6 in edges' do
|
228
|
+
to_v.in_edges.count.should == 6
|
229
|
+
end
|
230
|
+
|
231
|
+
specify 'to_v should have 3 in edges with label a' do
|
232
|
+
to_v.in_edges('a').count.should == 3
|
233
|
+
end
|
234
|
+
|
235
|
+
specify 'to_v should have 4 in edges with label a or c' do
|
236
|
+
to_v.in_edges('a', 'c').count.should == 4
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'should add an extension' do
|
240
|
+
edge = to_v.in_edges(Tackle::SimpleMixin).first
|
241
|
+
edge.should be_a(Pacer::Wrappers::EdgeWrapper)
|
242
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
243
|
+
end
|
244
|
+
|
245
|
+
it 'should be able to mix labels and mixins as arguments' do
|
246
|
+
edge = to_v.in_edges('a', Tackle::SimpleMixin, 'b').first
|
247
|
+
edge.should be_a(Pacer::Wrappers::EdgeWrapper)
|
248
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should filter correctly with a mix of labels and mixins as arguments' do
|
252
|
+
to_v.in_edges('a', Tackle::SimpleMixin, 'b').count.should == 5
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
describe '#out_edges' do
|
257
|
+
specify 'from_v should have 6 out edges' do
|
258
|
+
from_v.out_edges.count.should == 6
|
259
|
+
end
|
260
|
+
|
261
|
+
specify 'from_v should have 3 out edges with label a' do
|
262
|
+
from_v.out_edges('a').count.should == 3
|
263
|
+
end
|
264
|
+
|
265
|
+
specify 'from_v should have 4 out edges with label a or c' do
|
266
|
+
from_v.out_edges('a', 'c').count.should == 4
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'should add an extension' do
|
270
|
+
edge = from_v.out_edges(Tackle::SimpleMixin).first
|
271
|
+
edge.should be_a(Pacer::Wrappers::EdgeWrapper)
|
272
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'should be able to mix labels and mixins as arguments' do
|
276
|
+
edge = from_v.out_edges('a', Tackle::SimpleMixin, 'b').first
|
277
|
+
edge.should be_a(Pacer::Wrappers::EdgeWrapper)
|
278
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'should filter correctly with a mix of labels and mixins as arguments' do
|
282
|
+
from_v.out_edges('a', Tackle::SimpleMixin, 'b').count.should == 5
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe '#both_edges' do
|
287
|
+
specify 'from_v should have 6 edges' do
|
288
|
+
from_v.both_edges.count.should == 6
|
289
|
+
end
|
290
|
+
|
291
|
+
specify 'from_v should have 3 edges with label a' do
|
292
|
+
from_v.both_edges('a').count.should == 3
|
293
|
+
end
|
294
|
+
|
295
|
+
specify 'from_v should have 4 edges with label a or c' do
|
296
|
+
from_v.both_edges('a', 'c').count.should == 4
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should add an extension' do
|
300
|
+
edge = from_v.both_edges(Tackle::SimpleMixin).first
|
301
|
+
edge.should be_a(Pacer::Wrappers::EdgeWrapper)
|
302
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
303
|
+
end
|
304
|
+
|
305
|
+
it 'should be able to mix labels and mixins as arguments' do
|
306
|
+
edge = from_v.both_edges('a', Tackle::SimpleMixin, 'b').first
|
307
|
+
edge.should be_a(Pacer::Wrappers::EdgeWrapper)
|
308
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'should filter correctly with a mix of labels and mixins as arguments' do
|
312
|
+
from_v.both_edges('a', Tackle::SimpleMixin, 'b').count.should == 5
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
Run.all do
|
319
|
+
it_uses Pacer::Wrappers::VertexWrapper
|
320
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
def maybe_require(file)
|
2
|
+
require file
|
3
|
+
rescue LoadError
|
4
|
+
puts "Not using #{ file }"
|
5
|
+
end
|
6
|
+
|
1
7
|
require "rubygems"
|
2
8
|
require "bundler"
|
3
9
|
Bundler.setup(:default, :development)
|
@@ -5,6 +11,9 @@ require 'rspec'
|
|
5
11
|
require 'pacer'
|
6
12
|
require 'set'
|
7
13
|
|
14
|
+
require 'simplecov'
|
15
|
+
SimpleCov.start if ENV['COVERAGE']
|
16
|
+
|
8
17
|
Dir['./spec/support/**/*.rb'].map {|f| require f}
|
9
18
|
Dir['./spec/tackle/*.rb'].map {|f| require f}
|
10
19
|
|
@@ -20,9 +29,9 @@ def in_editor?
|
|
20
29
|
ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
|
21
30
|
end
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
|
32
|
+
maybe_require 'pacer-neo4j'
|
33
|
+
maybe_require 'pacer-orient'
|
34
|
+
maybe_require 'pacer-dex'
|
26
35
|
|
27
36
|
Run = RSpec::GraphRunner.new ENV['GRAPHS']
|
28
37
|
|
@@ -38,11 +47,11 @@ def use_pacer_graphml_data(usage_style = :read_write)
|
|
38
47
|
if usage_style == :read_only
|
39
48
|
let(:setup_data) { }
|
40
49
|
before(:all) do
|
41
|
-
|
50
|
+
Pacer::GraphML.import graph, 'spec/data/pacer.graphml' if graph
|
42
51
|
end
|
43
52
|
else
|
44
53
|
let(:setup_data) do
|
45
|
-
|
54
|
+
Pacer::GraphML.import graph, 'spec/data/pacer.graphml' if graph
|
46
55
|
end
|
47
56
|
end
|
48
57
|
let(:pangloss) { graph.v(:name => 'pangloss', :type => 'person').first }
|
@@ -55,11 +64,11 @@ def use_grateful_dead_data(usage_style = :read_write)
|
|
55
64
|
if usage_style == :read_only
|
56
65
|
let(:setup_data) { }
|
57
66
|
before(:all) do
|
58
|
-
|
67
|
+
Pacer::GraphML.import graph, 'spec/data/grateful-dead.xml' if graph
|
59
68
|
end
|
60
69
|
else
|
61
70
|
let(:setup_data) do
|
62
|
-
|
71
|
+
Pacer::GraphML.import graph, 'spec/data/grateful-dead.xml' if graph
|
63
72
|
end
|
64
73
|
end
|
65
74
|
end
|
@@ -1,4 +1,31 @@
|
|
1
|
+
maybe_require 'pacer-neo4j/rspec'
|
2
|
+
maybe_require 'pacer-orient/rspec'
|
3
|
+
maybe_require 'pacer-dex/rspec'
|
4
|
+
|
1
5
|
class RSpec::GraphRunner
|
6
|
+
module Stubs
|
7
|
+
def all(*args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def tg(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def neo4j(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def rg(*args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def multigraph(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def dex(*args)
|
23
|
+
end
|
24
|
+
|
25
|
+
def orient(*args)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
2
29
|
module Tg
|
3
30
|
def all(usage_style = :read_write, indices = true, &block)
|
4
31
|
tg(usage_style, indices, &block)
|
@@ -7,21 +34,11 @@ class RSpec::GraphRunner
|
|
7
34
|
def tg(usage_style = :read_write, indices = true, &block)
|
8
35
|
return unless use_graph? 'tg'
|
9
36
|
describe 'tg' do
|
10
|
-
let(:graph)
|
11
|
-
g = Pacer.tg
|
12
|
-
unless indices
|
13
|
-
g.drop_index :vertices
|
14
|
-
g.drop_index :edges
|
15
|
-
end
|
16
|
-
g
|
17
|
-
end
|
37
|
+
let(:graph) { Pacer.tg }
|
18
38
|
let(:graph2) { Pacer.tg }
|
19
39
|
instance_eval(&block)
|
20
40
|
end
|
21
41
|
end
|
22
|
-
|
23
|
-
def dex(*args)
|
24
|
-
end
|
25
42
|
end
|
26
43
|
|
27
44
|
module RubyGraph
|
@@ -37,11 +54,11 @@ class RSpec::GraphRunner
|
|
37
54
|
protected
|
38
55
|
|
39
56
|
def ruby_graph
|
40
|
-
Pacer::RubyGraph.new
|
57
|
+
Pacer::PacerGraph.new Pacer::SimpleEncoder, proc { Pacer::RubyGraph.new }
|
41
58
|
end
|
42
59
|
|
43
60
|
def ruby_graph2
|
44
|
-
Pacer::RubyGraph.new
|
61
|
+
Pacer::PacerGraph.new Pacer::SimpleEncoder, proc { Pacer::RubyGraph.new }
|
45
62
|
end
|
46
63
|
end
|
47
64
|
|
@@ -58,17 +75,22 @@ class RSpec::GraphRunner
|
|
58
75
|
protected
|
59
76
|
|
60
77
|
def multi_graph
|
61
|
-
Pacer::MultiGraph.
|
78
|
+
Pacer::MultiGraph.blank
|
62
79
|
end
|
63
80
|
|
64
81
|
def multi_graph2
|
65
|
-
Pacer::MultiGraph.
|
82
|
+
Pacer::MultiGraph.blank
|
66
83
|
end
|
67
84
|
end
|
68
85
|
|
86
|
+
|
87
|
+
include Stubs
|
69
88
|
include Tg
|
70
|
-
include RubyGraph
|
71
|
-
include MultiGraph
|
89
|
+
#include RubyGraph
|
90
|
+
#include MultiGraph
|
91
|
+
include Neo4j if defined? Neo4j
|
92
|
+
include Dex if defined? Dex
|
93
|
+
include Orient if defined? Orient
|
72
94
|
|
73
95
|
def initialize(*graphs)
|
74
96
|
@graphs = graphs.map { |s| s.to_s.downcase.split(/\s*,\s*/) }.flatten.map { |s| s.strip }.reject { |s| s == '' }
|
@@ -94,6 +116,7 @@ protected
|
|
94
116
|
|
95
117
|
def for_graph(name, usage_style, indices, transactions, source_graph_1, source_graph_2, unindexed_graph, block)
|
96
118
|
return unless use_graph? name
|
119
|
+
clear_graph = proc { |g| clear g }
|
97
120
|
describe name do
|
98
121
|
let(:graph) do
|
99
122
|
if indices
|
@@ -107,27 +130,32 @@ protected
|
|
107
130
|
end
|
108
131
|
if usage_style == :read_only
|
109
132
|
before(:all) do
|
110
|
-
|
111
|
-
|
112
|
-
|
133
|
+
if indices
|
134
|
+
clear_graph.call source_graph_1
|
135
|
+
elsif unindexed_graph
|
136
|
+
clear_graph.call unindexed_graph
|
137
|
+
end
|
138
|
+
clear_graph.call source_graph_2
|
113
139
|
end
|
114
140
|
end
|
115
141
|
around do |spec|
|
116
142
|
if usage_style == :read_write
|
117
|
-
|
118
|
-
|
119
|
-
|
143
|
+
if indices
|
144
|
+
clear_graph.call source_graph_1
|
145
|
+
elsif unindexed_graph
|
146
|
+
clear_graph.call unindexed_graph
|
147
|
+
end
|
148
|
+
clear_graph.call source_graph_2
|
120
149
|
end
|
121
150
|
if transactions and spec.use_transactions?
|
122
|
-
graph.
|
123
|
-
graph2.
|
151
|
+
graph.transaction do |g1_commit, g1_rollback|
|
152
|
+
graph2.transaction do |_, g2_rollback|
|
153
|
+
spec.metadata[:graph_commit] = g1_commit
|
124
154
|
begin
|
125
|
-
graph.begin_transaction
|
126
|
-
graph2.begin_transaction
|
127
155
|
spec.run
|
128
156
|
ensure
|
129
|
-
|
130
|
-
|
157
|
+
g1_rollback.call rescue nil
|
158
|
+
g2_rollback.call rescue nil
|
131
159
|
end
|
132
160
|
end
|
133
161
|
end
|
@@ -138,5 +166,28 @@ protected
|
|
138
166
|
instance_eval(&block)
|
139
167
|
end
|
140
168
|
end
|
169
|
+
|
170
|
+
def clear(graph)
|
171
|
+
graph.transaction do
|
172
|
+
graph.blueprints_graph.getVertices.each do |v|
|
173
|
+
begin
|
174
|
+
graph.remove_vertex v
|
175
|
+
rescue
|
176
|
+
end
|
177
|
+
end
|
178
|
+
graph.indices.each do |idx|
|
179
|
+
graph.drop_index idx.index_name
|
180
|
+
end
|
181
|
+
end
|
182
|
+
#if graph.v.any?
|
183
|
+
# fail "Graph still has vertices"
|
184
|
+
#elsif graph.e.any?
|
185
|
+
# fail "Graph still has edges"
|
186
|
+
#elsif graph.indices.any?
|
187
|
+
# fail "Graph still has indices"
|
188
|
+
#elsif graph.key_indices.any?
|
189
|
+
# fail "Graph still has key indices"
|
190
|
+
#end
|
191
|
+
end
|
141
192
|
end
|
142
193
|
|