pacer 1.0.2-java → 1.0.3-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data/blog/2012-09-18-pacer-1.0.md +63 -0
  2. data/lib/pacer/core/graph/element_route.rb +8 -4
  3. data/lib/pacer/core/graph/vertices_route.rb +1 -1
  4. data/lib/pacer/core/route.rb +20 -0
  5. data/lib/pacer/exceptions.rb +1 -0
  6. data/lib/pacer/filter/future_filter.rb +2 -0
  7. data/lib/pacer/graph/graph_transactions_mixin.rb +13 -12
  8. data/lib/pacer/graph/hash_index.rb +29 -0
  9. data/lib/pacer/graph/pacer_graph.rb +23 -6
  10. data/lib/pacer/graph/simple_encoder.rb +9 -4
  11. data/lib/pacer/graph/yaml_encoder.rb +18 -31
  12. data/lib/pacer/loader.rb +93 -0
  13. data/lib/pacer/route/mixin/bulk_operations.rb +1 -1
  14. data/lib/pacer/route.rb +0 -151
  15. data/lib/pacer/route_builder.rb +142 -0
  16. data/lib/pacer/side_effect/as.rb +1 -3
  17. data/lib/pacer/version.rb +1 -1
  18. data/lib/pacer/wrappers/edge_wrapper.rb +13 -16
  19. data/lib/pacer/wrappers/element_wrapper.rb +12 -22
  20. data/lib/pacer/wrappers/vertex_wrapper.rb +7 -4
  21. data/lib/{pacer-1.0.2-standalone.jar → pacer-1.0.3-standalone.jar} +0 -0
  22. data/lib/pacer.rb +9 -15
  23. data/pom.xml +1 -1
  24. data/spec/pacer/blueprints/dex_spec.rb +1 -154
  25. data/spec/pacer/blueprints/neo4j_spec.rb +8 -154
  26. data/spec/pacer/blueprints/orient_spec.rb +5 -0
  27. data/spec/pacer/blueprints/tg_spec.rb +1 -76
  28. data/spec/pacer/core/graph/vertices_route_spec.rb +32 -5
  29. data/spec/pacer/graph/pacer_graph_spec.rb +304 -336
  30. data/spec/pacer/graph/simple_encoder_spec.rb +78 -0
  31. data/spec/pacer/graph/yaml_encoder_spec.rb +71 -0
  32. data/spec/pacer/transform/join_spec.rb +1 -1
  33. data/spec/pacer/utils/tsort_spec.rb +1 -3
  34. data/spec/pacer/wrapper/edge_wrapper_spec.rb +46 -40
  35. data/spec/pacer/wrapper/element_wrapper_spec.rb +8 -13
  36. data/spec/support/graph_runner.rb +12 -3
  37. metadata +13 -14
  38. data/lib/pacer/blueprints.rb +0 -3
  39. data/lib/pacer/core.rb +0 -8
  40. data/lib/pacer/filter.rb +0 -17
  41. data/lib/pacer/graph.rb +0 -12
  42. data/lib/pacer/route/mixins.rb +0 -2
  43. data/lib/pacer/routes.rb +0 -6
  44. data/lib/pacer/side_effect.rb +0 -11
  45. data/lib/pacer/support.rb +0 -10
  46. data/lib/pacer/transform.rb +0 -16
  47. data/lib/pacer/visitors.rb +0 -7
  48. data/lib/pacer/wrappers.rb +0 -21
@@ -16,104 +16,125 @@ shared_examples_for 'a vertex with a mixin' do
16
16
  end
17
17
  end
18
18
 
19
- shared_examples_for Pacer::RubyGraph do
20
- let(:v0) { graph.create_vertex }
21
- let(:v1) { graph.create_vertex }
22
- let(:e0) { graph.create_edge nil, v0, v1, :links }
23
- let(:e1) { graph.create_edge nil, v0, v1, :relinks }
24
- before do
25
- e0 # force edge and vertices to be created.
26
- end
27
-
28
- describe '#vertex' do
29
- context 'not found' do
30
- subject { graph.vertex '-1' }
31
- it { should be_nil }
32
- end
33
-
34
- subject { graph.vertex v0.element_id }
35
- its(:element_id) { should == v0.element_id }
36
- its(:graph) { should == graph }
19
+ Run.all :read_write do
20
+ describe Pacer::PacerGraph do
21
+ use_simple_graph_data
22
+ before { setup_data }
23
+
24
+ describe '#vertex' do
25
+ context 'not found' do
26
+ subject { graph.vertex '-1' }
27
+ it { should be_nil }
28
+ end
37
29
 
38
- context 'with mixins' do
39
- subject { graph.vertex v0.element_id, Tackle::SimpleMixin }
30
+ subject { graph.vertex v0.element_id }
40
31
  its(:element_id) { should == v0.element_id }
41
- it_behaves_like 'a vertex with a mixin'
42
- end
32
+ its(:graph) { should == graph }
43
33
 
44
- context 'with a wrapper' do
45
- let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
46
- subject { graph.vertex v0.element_id, wrapper }
47
- its(:element_id) { should == v0.element_id }
48
- its(:class) { should == wrapper }
49
- it_behaves_like 'a vertex with a mixin'
50
- end
34
+ context 'with mixins' do
35
+ subject { graph.vertex v0.element_id, Tackle::SimpleMixin }
36
+ its(:element_id) { should == v0.element_id }
37
+ it_behaves_like 'a vertex with a mixin'
38
+ end
51
39
 
52
- context 'with a wrapper and a mixin' do
53
- let(:orig_wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
54
- let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin, TP::Person }
55
- subject { graph.vertex v0.element_id, TP::Person, orig_wrapper }
56
- its(:element_id) { should == v0.element_id }
57
- its(:class) { should_not == orig_wrapper }
58
- its(:class) { should == wrapper }
59
- it_behaves_like 'a vertex with a mixin'
60
- end
61
- end
40
+ context 'with a wrapper' do
41
+ let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
42
+ subject { graph.vertex v0.element_id, wrapper }
43
+ its(:element_id) { should == v0.element_id }
44
+ its(:class) { should == wrapper }
45
+ it_behaves_like 'a vertex with a mixin'
46
+ end
62
47
 
63
- describe '#edge' do
64
- context 'not found' do
65
- subject { graph.edge '-1' }
66
- it { should be_nil }
48
+ context 'with a wrapper and a mixin' do
49
+ let(:orig_wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
50
+ let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin, TP::Person }
51
+ subject { graph.vertex v0.element_id, TP::Person, orig_wrapper }
52
+ its(:element_id) { should == v0.element_id }
53
+ its(:class) { should_not == orig_wrapper }
54
+ its(:class) { should == wrapper }
55
+ it_behaves_like 'a vertex with a mixin'
56
+ end
67
57
  end
68
58
 
69
- subject { graph.edge e0.element_id }
70
- its(:element_id) { should == e0.element_id }
71
- its(:graph) { should == graph }
59
+ describe '#edge' do
60
+ context 'not found' do
61
+ subject { graph.edge '-1' }
62
+ it { should be_nil }
63
+ end
72
64
 
73
- context 'with mixins' do
74
- subject { graph.edge e0.element_id, Tackle::SimpleMixin }
65
+ subject { graph.edge e0.element_id }
75
66
  its(:element_id) { should == e0.element_id }
76
- it_behaves_like 'an edge with a mixin'
77
- end
67
+ its(:graph) { should == graph }
78
68
 
79
- context 'with a wrapper' do
80
- let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
81
- subject { graph.edge e0.element_id, wrapper }
82
- its(:element_id) { should == e0.element_id }
83
- its(:class) { should == wrapper }
84
- it_behaves_like 'an edge with a mixin'
85
- end
69
+ context 'with mixins' do
70
+ subject { graph.edge e0.element_id, Tackle::SimpleMixin }
71
+ its(:element_id) { should == e0.element_id }
72
+ it_behaves_like 'an edge with a mixin'
73
+ end
86
74
 
87
- context 'with a wrapper and a mixin' do
88
- let(:orig_wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
89
- let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin, TP::Wrote }
90
- subject { graph.edge e0.element_id, orig_wrapper, TP::Wrote }
91
- its(:element_id) { should == e0.element_id }
92
- its(:class) { should_not == orig_wrapper }
93
- its(:class) { should == wrapper }
94
- it_behaves_like 'an edge with a mixin'
75
+ context 'with a wrapper' do
76
+ let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
77
+ subject { graph.edge e0.element_id, wrapper }
78
+ its(:element_id) { should == e0.element_id }
79
+ its(:class) { should == wrapper }
80
+ it_behaves_like 'an edge with a mixin'
81
+ end
82
+
83
+ context 'with a wrapper and a mixin' do
84
+ let(:orig_wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
85
+ let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin, TP::Wrote }
86
+ subject { graph.edge e0.element_id, orig_wrapper, TP::Wrote }
87
+ its(:element_id) { should == e0.element_id }
88
+ its(:class) { should_not == orig_wrapper }
89
+ its(:class) { should == wrapper }
90
+ it_behaves_like 'an edge with a mixin'
91
+ end
95
92
  end
96
- end
97
93
 
98
- describe '#create_vertex' do
99
- let(:use_id) { rand 1000000 }
94
+ describe '#create_vertex' do
95
+ let(:use_id) { rand 1000000 }
100
96
 
101
- context 'existing' do
102
- it 'should raise an exception' do
103
- unless graph.features.ignoresSuppliedIds
104
- expect { graph.create_vertex v0.element_id }.to raise_error(Pacer::ElementExists)
97
+ context 'existing' do
98
+ it 'should raise an exception' do
99
+ unless graph.features.ignoresSuppliedIds
100
+ expect { graph.create_vertex v0.element_id }.to raise_error(Pacer::ElementExists)
101
+ end
105
102
  end
106
103
  end
107
- end
108
104
 
109
- context 'with properties' do
110
- subject { graph.create_vertex :name => 'Frank' }
111
- it { subject[:name].should == 'Frank' }
112
- its(:element_id) { should_not be_nil }
105
+ context 'with properties' do
106
+ subject { graph.create_vertex :name => 'Frank' }
107
+ it { subject[:name].should == 'Frank' }
108
+ its(:element_id) { should_not be_nil }
109
+
110
+ context 'and an id' do
111
+ subject { graph.create_vertex use_id, :name => 'Steve' }
112
+ it { subject[:name].should == 'Steve' }
113
+ its('element_id.to_s') do
114
+ if graph.respond_to? :id_prefix
115
+ should == graph.id_prefix + use_id.to_s
116
+ elsif not graph.features.ignoresSuppliedIds
117
+ should == use_id.to_s
118
+ end
119
+ end
120
+
121
+ context 'and mixins' do
122
+ subject { graph.create_vertex use_id, Tackle::SimpleMixin, :name => 'John' }
123
+ it { subject[:name].should == 'John' }
124
+ its('element_id.to_s') do
125
+ if graph.respond_to? :id_prefix
126
+ should == graph.id_prefix + use_id.to_s
127
+ elsif not graph.features.ignoresSuppliedIds
128
+ should == use_id.to_s
129
+ end
130
+ end
131
+ it_behaves_like 'a vertex with a mixin'
132
+ end
133
+ end
134
+ end
113
135
 
114
- context 'and an id' do
115
- subject { graph.create_vertex use_id, :name => 'Steve' }
116
- it { subject[:name].should == 'Steve' }
136
+ context 'with an id' do
137
+ subject { graph.create_vertex use_id }
117
138
  its('element_id.to_s') do
118
139
  if graph.respond_to? :id_prefix
119
140
  should == graph.id_prefix + use_id.to_s
@@ -123,8 +144,7 @@ shared_examples_for Pacer::RubyGraph do
123
144
  end
124
145
 
125
146
  context 'and mixins' do
126
- subject { graph.create_vertex use_id, Tackle::SimpleMixin, :name => 'John' }
127
- it { subject[:name].should == 'John' }
147
+ subject { graph.create_vertex use_id, Tackle::SimpleMixin }
128
148
  its('element_id.to_s') do
129
149
  if graph.respond_to? :id_prefix
130
150
  should == graph.id_prefix + use_id.to_s
@@ -135,333 +155,281 @@ shared_examples_for Pacer::RubyGraph do
135
155
  it_behaves_like 'a vertex with a mixin'
136
156
  end
137
157
  end
138
- end
139
158
 
140
- context 'with an id' do
141
- subject { graph.create_vertex use_id }
142
- its('element_id.to_s') do
143
- if graph.respond_to? :id_prefix
144
- should == graph.id_prefix + use_id.to_s
145
- elsif not graph.features.ignoresSuppliedIds
146
- should == use_id.to_s
147
- end
159
+ context 'with mixins' do
160
+ subject { graph.create_vertex Tackle::SimpleMixin }
161
+ it_behaves_like 'a vertex with a mixin'
148
162
  end
163
+ end
149
164
 
150
- context 'and mixins' do
151
- subject { graph.create_vertex use_id, Tackle::SimpleMixin }
152
- its('element_id.to_s') do
153
- if graph.respond_to? :id_prefix
154
- should == graph.id_prefix + use_id.to_s
155
- elsif not graph.features.ignoresSuppliedIds
156
- should == use_id.to_s
165
+
166
+ describe '#create_edge' do
167
+ let(:use_id) { rand 1000000 }
168
+ let(:from) { graph.vertex v0.element_id }
169
+ let(:to) { graph.vertex v1.element_id }
170
+
171
+ context 'existing' do
172
+ it 'should raise an exception' do
173
+ if not graph.features.ignoresSuppliedIds
174
+ expect { graph.create_edge e0.element_id, from, to, :connects }.to raise_error(Pacer::ElementExists)
157
175
  end
158
176
  end
159
- it_behaves_like 'a vertex with a mixin'
160
177
  end
161
- end
162
-
163
- context 'with mixins' do
164
- subject { graph.create_vertex Tackle::SimpleMixin }
165
- it_behaves_like 'a vertex with a mixin'
166
- end
167
- end
168
178
 
179
+ context 'with properties' do
180
+ subject { graph.create_edge nil, from, to, :connects, :name => 'Frank' }
181
+ it { subject[:name].should == 'Frank' }
182
+ its(:label) { should == 'connects' }
183
+ its(:element_id) { should_not be_nil }
169
184
 
170
- describe '#create_edge' do
171
- let(:use_id) { rand 1000000 }
172
- let(:from) { graph.vertex v0.element_id }
173
- let(:to) { graph.vertex v1.element_id }
185
+ context 'and an id' do
186
+ subject { graph.create_edge use_id, from, to, :connects, :name => 'Steve' }
187
+ it { subject[:name].should == 'Steve' }
188
+ its(:label) { should == 'connects' }
189
+ its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
174
190
 
175
- context 'existing' do
176
- it 'should raise an exception' do
177
- if not graph.features.ignoresSuppliedIds
178
- expect { graph.create_edge e0.element_id, from, to, :connects }.to raise_error(Pacer::ElementExists)
191
+ context 'and mixins' do
192
+ subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin, :name => 'John' }
193
+ it { subject[:name].should == 'John' }
194
+ its(:label) { should == 'connects' }
195
+ its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
196
+ it_behaves_like 'an edge with a mixin'
197
+ end
179
198
  end
180
199
  end
181
- end
182
-
183
- context 'with properties' do
184
- subject { graph.create_edge nil, from, to, :connects, :name => 'Frank' }
185
- it { subject[:name].should == 'Frank' }
186
- its(:label) { should == 'connects' }
187
- its(:element_id) { should_not be_nil }
188
200
 
189
- context 'and an id' do
190
- subject { graph.create_edge use_id, from, to, :connects, :name => 'Steve' }
191
- it { subject[:name].should == 'Steve' }
201
+ context 'with an id' do
202
+ subject { graph.create_edge use_id, from, to, :connects }
192
203
  its(:label) { should == 'connects' }
193
204
  its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
194
205
 
195
206
  context 'and mixins' do
196
- subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin, :name => 'John' }
197
- it { subject[:name].should == 'John' }
207
+ subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin }
198
208
  its(:label) { should == 'connects' }
199
209
  its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
200
210
  it_behaves_like 'an edge with a mixin'
201
211
  end
202
212
  end
203
- end
204
-
205
- context 'with an id' do
206
- subject { graph.create_edge use_id, from, to, :connects }
207
- its(:label) { should == 'connects' }
208
- its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
209
213
 
210
- context 'and mixins' do
211
- subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin }
214
+ context 'with mixins' do
215
+ subject { graph.create_edge nil, from, to, :connects, Tackle::SimpleMixin }
212
216
  its(:label) { should == 'connects' }
213
- its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
214
217
  it_behaves_like 'an edge with a mixin'
215
218
  end
216
219
  end
217
220
 
218
- context 'with mixins' do
219
- subject { graph.create_edge nil, from, to, :connects, Tackle::SimpleMixin }
220
- its(:label) { should == 'connects' }
221
- it_behaves_like 'an edge with a mixin'
222
- end
223
- end
224
-
225
- describe '#bulk_job_size' do
226
- subject { graph.bulk_job_size }
227
- describe 'default' do
228
- it { should == 5000 }
229
- end
230
- describe 'custom' do
231
- before { graph.bulk_job_size = 12 }
232
- it { should == 12 }
221
+ describe '#bulk_job_size' do
222
+ subject { graph.bulk_job_size }
223
+ describe 'default' do
224
+ it { should == 5000 }
225
+ end
226
+ describe 'custom' do
227
+ before { graph.bulk_job_size = 12 }
228
+ it { should == 12 }
229
+ end
233
230
  end
234
- end
235
231
 
236
- describe '#in_bulk_job?' do
237
- subject { graph.in_bulk_job? }
238
- it { should be_false }
232
+ describe '#in_bulk_job?' do
233
+ subject { graph.in_bulk_job? }
234
+ it { should be_false }
239
235
 
240
- context 'in bulk job' do
241
- around do |spec|
242
- graph.v[0].bulk_job do
243
- spec.call
236
+ context 'in bulk job' do
237
+ around do |spec|
238
+ graph.v[0].bulk_job do
239
+ spec.call
240
+ end
244
241
  end
242
+ it { should be_true }
245
243
  end
246
- it { should be_true }
247
244
  end
248
- end
249
245
 
250
- describe '#load_vertices' do
251
- context 'invalid' do
252
- subject { graph.load_vertices [v0.element_id, nil, v0.element_id, 'missing'] }
253
- it { should == [v0, v0] }
254
- end
246
+ describe '#load_vertices' do
247
+ context 'invalid' do
248
+ subject { graph.load_vertices [v0.element_id, nil, v0.element_id, 'missing'] }
249
+ it { should == [v0, v0] }
250
+ end
255
251
 
256
- context 'valid' do
257
- subject { graph.load_vertices [v0.element_id, v1.element_id] }
258
- it { should == [v0, v1] }
252
+ context 'valid' do
253
+ subject { graph.load_vertices [v0.element_id, v1.element_id] }
254
+ it { should == [v0, v1] }
255
+ end
259
256
  end
260
- end
261
257
 
262
- describe '#load_edges' do
263
- before do
264
- c = example.metadata[:graph_commit]
265
- c.call if c
266
- end
267
- context 'invalid' do
268
- subject { graph.load_edges [e0.element_id, nil, e0.element_id, 'missing'] }
269
- it { should == [e0, e0] }
270
- end
258
+ describe '#load_edges' do
259
+ before do
260
+ c = example.metadata[:graph_commit]
261
+ c.call if c
262
+ end
263
+ context 'invalid' do
264
+ subject { graph.load_edges [e0.element_id, nil, e0.element_id, 'missing'] }
265
+ it { should == [e0, e0] }
266
+ end
271
267
 
272
- context 'valid' do
273
- subject { graph.load_edges [e0.element_id] }
274
- it { should == [e0] }
268
+ context 'valid' do
269
+ subject { graph.load_edges [e0.element_id] }
270
+ it { should == [e0] }
271
+ end
275
272
  end
276
- end
277
273
 
278
- describe '#index' do
279
- it 'should have no indices' do
280
- graph.indices.count.should == 0 if graph.features.supportsKeyIndices
281
- end
274
+ describe '#index' do
275
+ it 'should have no indices' do
276
+ graph.indices.count.should == 0 if graph.features.supportsKeyIndices
277
+ end
282
278
 
283
- context 'missing' do
284
- around { |spec| spec.run if graph.features.supportsIndices }
285
- subject { graph.index 'invalid' }
286
- it { should be_nil }
287
- context 'edge' do
288
- before do
289
- graph.drop_index 'missing_edge' rescue nil
290
- graph.index('missing_edge').should be_nil
291
- end
292
- subject { graph.index 'missing_edge', :edge, :create => true }
293
- its(:name) { should == 'missing_edge' }
294
- after do
295
- graph.transaction do
296
- graph.drop_index 'missing_edge'
279
+ context 'missing' do
280
+ around { |spec| spec.run if graph.features.supportsIndices }
281
+ subject { graph.index 'invalid' }
282
+ it { should be_nil }
283
+ context 'edge' do
284
+ before do
285
+ graph.drop_index 'missing_edge' rescue nil
286
+ graph.index('missing_edge').should be_nil
287
+ end
288
+ subject { graph.index 'missing_edge', :edge, :create => true }
289
+ its(:name) { should == 'missing_edge' }
290
+ after do
291
+ graph.transaction(nesting: true) do
292
+ graph.drop_index 'missing_edge'
293
+ end
297
294
  end
298
295
  end
299
- end
300
296
 
301
- context 'vertex' do
302
- before do
303
- graph.drop_index 'missing_vertex' rescue nil
304
- graph.index('missing_vertex').should be_nil
305
- end
306
- subject { graph.index 'missing_vertex', :vertex, :create => true }
307
- its(:name) { should == 'missing_vertex' }
308
- after do
309
- graph.transaction do
310
- graph.drop_index 'missing_vertex'
297
+ context 'vertex' do
298
+ before do
299
+ graph.drop_index 'missing_vertex' rescue nil
300
+ graph.index('missing_vertex').should be_nil
301
+ end
302
+ subject { graph.index 'missing_vertex', :vertex, :create => true }
303
+ its(:name) { should == 'missing_vertex' }
304
+ after do
305
+ graph.transaction(nesting: true) do
306
+ graph.drop_index 'missing_vertex'
307
+ end
311
308
  end
312
309
  end
313
310
  end
314
311
  end
315
- end
316
312
 
317
- describe '#graph' do
318
- subject { graph.graph }
319
- it { should == graph }
320
- end
313
+ describe '#graph' do
314
+ subject { graph.graph }
315
+ it { should == graph }
316
+ end
321
317
 
322
- describe '#vertex_name' do
323
- before { graph.vertex_name = :some_proc }
324
- subject { graph.vertex_name }
325
- it { should == :some_proc }
326
- after { graph.vertex_name = nil }
327
- end
318
+ describe '#vertex_name' do
319
+ before { graph.vertex_name = :some_proc }
320
+ subject { graph.vertex_name }
321
+ it { should == :some_proc }
322
+ after { graph.vertex_name = nil }
323
+ end
328
324
 
329
- describe '#edge_name' do
330
- before { graph.edge_name = :some_proc }
331
- subject { graph.edge_name }
332
- it { should == :some_proc }
333
- after { graph.edge_name = nil }
334
- end
325
+ describe '#edge_name' do
326
+ before { graph.edge_name = :some_proc }
327
+ subject { graph.edge_name }
328
+ it { should == :some_proc }
329
+ after { graph.edge_name = nil }
330
+ end
331
+
332
+ describe '#import' do
333
+ it 'should load the data into an empty graph' do
334
+ graph2.v.delete!
335
+ graph2.v.count.should == 0
336
+ Pacer::GraphML.import graph2, 'spec/data/pacer.graphml'
337
+ graph2.v.count.should == 7
338
+ graph2.e.count.should == 14
339
+ end
335
340
 
336
- describe '#import' do
337
- it 'should load the data into an empty graph' do
338
- graph2.v.count.should == 0
339
- Pacer::GraphML.import graph2, 'spec/data/pacer.graphml'
340
- graph2.v.count.should == 7
341
- graph2.e.count.should == 14
341
+ it 'should not load the data into a graph with conflicting vertex ids' do
342
+ unless graph.features.ignoresSuppliedIds
343
+ graph.create_vertex '0' unless graph.vertex '0'
344
+ expect { Pacer::GraphML.import graph, 'spec/data/pacer.graphml' }.to raise_error(Pacer::ElementExists)
345
+ end
346
+ end
342
347
  end
343
348
 
344
- it 'should not load the data into a graph with conflicting vertex ids' do
345
- unless graph.features.ignoresSuppliedIds
346
- graph.create_vertex '0' unless graph.vertex '0'
347
- expect { Pacer::GraphML.import graph, 'spec/data/pacer.graphml' }.to raise_error(Pacer::ElementExists)
349
+ describe '#export' do
350
+ it 'should create a file that can be read back' do
351
+ graph.v.count.should == 2
352
+ graph.e.count.should == 2
353
+ Pacer::GraphML.export graph, 'tmp/graph_mixin_spec_export.graphml'
354
+ graph2.e.delete!
355
+ graph2.v.delete!
356
+ graph2.v.count.should == 0
357
+ graph2.e.count.should == 0
358
+ Pacer::GraphML.import graph2, 'tmp/graph_mixin_spec_export.graphml'
359
+ puts File.read 'tmp/graph_mixin_spec_export.graphml'
360
+ graph2.v.count.should == 2
361
+ graph2.e.count.should == 2
348
362
  end
349
363
  end
350
- end
351
364
 
352
- describe '#export' do
353
- it 'should create a file that can be read back' do
354
- graph.v.count.should == 2
355
- graph.e.count.should == 1
356
- graph2.e.delete!
357
- graph2.v.delete!
358
- graph2.v.count.should == 0
359
- graph2.e.count.should == 0
360
- Pacer::GraphML.export graph, 'tmp/graph_mixin_spec_export.graphml'
361
- Pacer::GraphML.import graph2, 'tmp/graph_mixin_spec_export.graphml'
362
- puts File.read 'tmp/graph_mixin_spec_export.graphml'
363
- graph2.v.count.should == 2
364
- graph2.e.count.should == 1
365
+ describe '#indices' do
366
+ subject { graph.indices.to_a }
367
+ it { should be_empty }
365
368
  end
366
- end
367
369
 
368
- end
370
+ describe '#element_type' do
371
+ context 'invalid' do
372
+ it { expect { graph.element_type(:nothing) }.to raise_error(ArgumentError) }
373
+ end
369
374
 
375
+ context ':vertex' do
376
+ subject { graph.element_type(:vertex) }
377
+ it { should == :vertex }
378
+ end
370
379
 
371
- Run.all :read_only, false do
372
- around do |spec|
373
- spec.run if graph
374
- end
380
+ context 'a vertex' do
381
+ subject { graph.element_type(v0) }
382
+ it { should == :vertex }
383
+ end
375
384
 
376
- let(:v0) { graph.create_vertex }
377
- let(:v1) { graph.create_vertex }
378
- let(:e0) { graph.create_edge nil, v0, v1, :links }
379
- let(:e1) { graph.create_edge nil, v0, v1, :relinks }
385
+ context ':edge' do
386
+ subject { graph.element_type(:edge) }
387
+ it { should == :edge }
388
+ end
380
389
 
381
- describe Pacer::RubyGraph do
382
- before do
383
- e0 # force edge and vertices to be created.
384
- end
390
+ context 'an edge' do
391
+ subject { graph.element_type(e0) }
392
+ it { should == :edge }
393
+ end
385
394
 
386
- pending "not sure if index rebuilding will be needed anymore" do
387
- describe 'rebuild_automatic_index', :transactions => false do
388
- context 'vertices' do
389
- before do
390
- v0.properties = { :name => 'darrick', :type => 'person' }
391
- v1.properties = { :name => 'eliza', :type => 'person' }
392
- @orig_idx = graph.createAutomaticIndex 'vertices', graph.index_class(:vertex), nil
393
- @new_idx = graph.rebuild_automatic_index @orig_idx
394
- end
395
+ context ':mixed' do
396
+ subject { graph.element_type(:mixed) }
397
+ it { should == :mixed }
398
+ end
395
399
 
396
- after do
397
- graph.drop_index :vertices
398
- graph.v.delete!
399
- end
400
+ context ':object' do
401
+ subject { graph.element_type(:object) }
402
+ it { should == :object }
403
+ end
400
404
 
401
- let(:orig_idx) { @orig_idx }
402
- subject { @new_idx }
403
- it { should_not equal(orig_idx) }
404
- it 'should not use the old vertices index' do
405
- graph.index('vertices').should_not equal(orig_idx)
406
- end
407
- it { should equal(graph.index('vertices')) }
408
- it 'should have 2 persons' do
409
- subject.count('type', 'person').should == 2
410
- end
411
- it 'should have v1 for eliza' do
412
- subject.get('name', 'eliza').to_a.should == [v1].to_a
413
- end
405
+ context 'from element_type' do
406
+ context ':vertex' do
407
+ subject { graph.element_type(graph.element_type :vertex) }
408
+ it { should == :vertex }
414
409
  end
415
410
 
416
- context 'edges' do
417
- before do
418
- v0.properties = { :name => 'darrick', :type => 'person' }
419
- v1.properties = { :name => 'eliza', :type => 'person' }
420
- e0.properties = { :style => 'edgy' }
421
- e1.properties = { :style => 'edgy' }
422
- @orig_idx = graph.createAutomaticIndex 'edges', graph.index_class(:edge), nil
423
- @new_idx = graph.rebuild_automatic_index @orig_idx
424
- end
425
-
426
- after do
427
- graph.drop_index :edges
428
- graph.v.delete!
429
- end
411
+ context ':edge' do
412
+ subject { graph.element_type(graph.element_type :edge) }
413
+ it { should == :edge }
414
+ end
430
415
 
416
+ context ':mixed' do
417
+ subject { graph.element_type(graph.element_type :mixed) }
418
+ it { should == :mixed }
419
+ end
431
420
 
432
- let(:orig_idx) { @orig_idx }
433
- subject { @new_idx }
434
- it { should_not equal(orig_idx) }
435
- it 'should not use the old edges index' do
436
- graph.index('edges').should_not equal(orig_idx)
437
- end
438
- it { should equal(graph.index('edges')) }
439
- it 'should have 1 edge' do
440
- subject.count('label', 'links').should == 1
441
- end
442
- it 'should have e0 and e1 for style => edgy' do
443
- subject.get('style', 'edgy').to_set.should == [e0, e1].to_set
444
- end
421
+ context ':object' do
422
+ subject { graph.element_type(graph.element_type :object) }
423
+ it { should == :object }
445
424
  end
446
425
  end
447
- end
448
- end
449
- end
450
426
 
451
- Run.all :read_write do
452
- it_uses Pacer::RubyGraph
453
- end
454
-
455
- Run.neo4j do
456
- describe '#vertex' do
457
- it 'should not raise an exception for invalid key type' do
458
- graph.vertex('bad id').should be_nil
459
- end
460
- end
461
-
462
- describe '#edge' do
463
- it 'should not raise an exception for invalid key type' do
464
- graph.edge('bad id').should be_nil
427
+ context 'from index_class' do
428
+ context ':vertex' do
429
+ subject { graph.element_type(graph.index_class :vertex) }
430
+ it { should == :vertex }
431
+ end
432
+ end
465
433
  end
466
434
  end
467
435
  end