pacer 1.0.2-java → 1.0.3-java
Sign up to get free protection for your applications and to get access to all the features.
- data/blog/2012-09-18-pacer-1.0.md +63 -0
- data/lib/pacer/core/graph/element_route.rb +8 -4
- data/lib/pacer/core/graph/vertices_route.rb +1 -1
- data/lib/pacer/core/route.rb +20 -0
- data/lib/pacer/exceptions.rb +1 -0
- data/lib/pacer/filter/future_filter.rb +2 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +13 -12
- data/lib/pacer/graph/hash_index.rb +29 -0
- data/lib/pacer/graph/pacer_graph.rb +23 -6
- data/lib/pacer/graph/simple_encoder.rb +9 -4
- data/lib/pacer/graph/yaml_encoder.rb +18 -31
- data/lib/pacer/loader.rb +93 -0
- data/lib/pacer/route/mixin/bulk_operations.rb +1 -1
- data/lib/pacer/route.rb +0 -151
- data/lib/pacer/route_builder.rb +142 -0
- data/lib/pacer/side_effect/as.rb +1 -3
- data/lib/pacer/version.rb +1 -1
- data/lib/pacer/wrappers/edge_wrapper.rb +13 -16
- data/lib/pacer/wrappers/element_wrapper.rb +12 -22
- data/lib/pacer/wrappers/vertex_wrapper.rb +7 -4
- data/lib/{pacer-1.0.2-standalone.jar → pacer-1.0.3-standalone.jar} +0 -0
- data/lib/pacer.rb +9 -15
- data/pom.xml +1 -1
- data/spec/pacer/blueprints/dex_spec.rb +1 -154
- data/spec/pacer/blueprints/neo4j_spec.rb +8 -154
- data/spec/pacer/blueprints/orient_spec.rb +5 -0
- data/spec/pacer/blueprints/tg_spec.rb +1 -76
- data/spec/pacer/core/graph/vertices_route_spec.rb +32 -5
- data/spec/pacer/graph/pacer_graph_spec.rb +304 -336
- data/spec/pacer/graph/simple_encoder_spec.rb +78 -0
- data/spec/pacer/graph/yaml_encoder_spec.rb +71 -0
- data/spec/pacer/transform/join_spec.rb +1 -1
- data/spec/pacer/utils/tsort_spec.rb +1 -3
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +46 -40
- data/spec/pacer/wrapper/element_wrapper_spec.rb +8 -13
- data/spec/support/graph_runner.rb +12 -3
- metadata +13 -14
- data/lib/pacer/blueprints.rb +0 -3
- data/lib/pacer/core.rb +0 -8
- data/lib/pacer/filter.rb +0 -17
- data/lib/pacer/graph.rb +0 -12
- data/lib/pacer/route/mixins.rb +0 -2
- data/lib/pacer/routes.rb +0 -6
- data/lib/pacer/side_effect.rb +0 -11
- data/lib/pacer/support.rb +0 -10
- data/lib/pacer/transform.rb +0 -16
- data/lib/pacer/visitors.rb +0 -7
- data/lib/pacer/wrappers.rb +0 -21
@@ -1,163 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
Run.neo4j do
|
4
|
-
|
5
|
-
let(:v0) { graph.create_vertex }
|
6
|
-
let(:v1) { graph.create_vertex }
|
7
|
-
let(:e0) { graph.create_edge '0', v0, v1, :default }
|
4
|
+
use_simple_graph_data
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
context ':vertex' do
|
15
|
-
subject { graph.element_type(:vertex) }
|
16
|
-
it { should == :vertex }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'a vertex' do
|
20
|
-
subject { graph.element_type(v0) }
|
21
|
-
it { should == :vertex }
|
22
|
-
end
|
23
|
-
|
24
|
-
context ':edge' do
|
25
|
-
subject { graph.element_type(:edge) }
|
26
|
-
it { should == :edge }
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'an edge' do
|
30
|
-
subject { graph.element_type(e0) }
|
31
|
-
it { should == :edge }
|
32
|
-
end
|
33
|
-
|
34
|
-
context ':mixed' do
|
35
|
-
subject { graph.element_type(:mixed) }
|
36
|
-
it { should == :mixed }
|
37
|
-
end
|
38
|
-
|
39
|
-
context ':object' do
|
40
|
-
subject { graph.element_type(:object) }
|
41
|
-
it { should == :object }
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'from element_type' do
|
45
|
-
context ':vertex' do
|
46
|
-
subject { graph.element_type(graph.element_type :vertex) }
|
47
|
-
it { should == :vertex }
|
48
|
-
end
|
49
|
-
|
50
|
-
context ':edge' do
|
51
|
-
subject { graph.element_type(graph.element_type :edge) }
|
52
|
-
it { should == :edge }
|
53
|
-
end
|
54
|
-
|
55
|
-
context ':mixed' do
|
56
|
-
subject { graph.element_type(graph.element_type :mixed) }
|
57
|
-
it { should == :mixed }
|
58
|
-
end
|
59
|
-
|
60
|
-
context ':object' do
|
61
|
-
subject { graph.element_type(graph.element_type :object) }
|
62
|
-
it { should == :object }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'from index_class' do
|
67
|
-
context ':vertex' do
|
68
|
-
subject { graph.element_type(graph.index_class :vertex) }
|
69
|
-
it { should == :vertex }
|
70
|
-
end
|
71
|
-
|
72
|
-
context ':edge' do
|
73
|
-
subject { graph.element_type(graph.index_class :edge) }
|
74
|
-
it { should == :edge }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#indices' do
|
80
|
-
subject { graph.indices.to_a }
|
81
|
-
its(:count) { should == 0 }
|
6
|
+
describe '#vertex' do
|
7
|
+
it 'should not raise an exception for invalid key type' do
|
8
|
+
graph.vertex('bad id').should be_nil
|
82
9
|
end
|
10
|
+
end
|
83
11
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
:symbol => :abba,
|
88
|
-
:empty => '',
|
89
|
-
:integer => 121,
|
90
|
-
:float => 100.001,
|
91
|
-
:time => Time.utc(1999, 11, 9, 9, 9, 1),
|
92
|
-
:object => { :a => 1, 1 => :a },
|
93
|
-
99 => 'numeric key',
|
94
|
-
'string key' => 'string value'
|
95
|
-
}
|
96
|
-
end
|
97
|
-
|
98
|
-
subject { graph.sanitize_properties original }
|
99
|
-
|
100
|
-
it { should_not equal(original) }
|
101
|
-
specify 'original should be unchanged' do
|
102
|
-
original.should == {
|
103
|
-
:string => ' bob ',
|
104
|
-
:symbol => :abba,
|
105
|
-
:empty => '',
|
106
|
-
:integer => 121,
|
107
|
-
:float => 100.001,
|
108
|
-
:time => Time.utc(1999, 11, 9, 9, 9, 1),
|
109
|
-
:object => { :a => 1, 1 => :a },
|
110
|
-
99 => 'numeric key',
|
111
|
-
'string key' => 'string value'
|
112
|
-
}
|
113
|
-
end
|
114
|
-
|
115
|
-
specify 'string should be stripped' do
|
116
|
-
subject[:string].should == 'bob'
|
117
|
-
end
|
118
|
-
|
119
|
-
specify 'empty string becomes nil' do
|
120
|
-
subject[:empty].should be_nil
|
121
|
-
end
|
122
|
-
|
123
|
-
specify 'numbers should be unmodified' do
|
124
|
-
subject[:integer].should == 121
|
125
|
-
subject[:float].should == 100.001
|
126
|
-
end
|
127
|
-
|
128
|
-
specify 'everything else should be yaml' do
|
129
|
-
subject[:time].should == YAML.dump(Time.utc(1999, 11, 9, 9, 9, 1))
|
130
|
-
end
|
131
|
-
|
132
|
-
its(:keys) { should == original.keys }
|
133
|
-
end
|
134
|
-
|
135
|
-
describe '#in_vertex' do
|
136
|
-
it 'should wrap the vertex' do
|
137
|
-
v = e0.in_vertex(Tackle::SimpleMixin)
|
138
|
-
v.should == v1
|
139
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'should wrap the vertex 2' do
|
143
|
-
v = e0.in_vertex([Tackle::SimpleMixin])
|
144
|
-
v.should == v1
|
145
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe '#out_vertex' do
|
150
|
-
it 'should wrap the vertex' do
|
151
|
-
v = e0.out_vertex(Tackle::SimpleMixin)
|
152
|
-
v.should == v0
|
153
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'should wrap the vertex 2' do
|
157
|
-
v = e0.out_vertex([Tackle::SimpleMixin])
|
158
|
-
v.should == v0
|
159
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
160
|
-
end
|
12
|
+
describe '#edge' do
|
13
|
+
it 'should not raise an exception for invalid key type' do
|
14
|
+
graph.edge('bad id').should be_nil
|
161
15
|
end
|
162
16
|
end
|
163
17
|
end
|
@@ -1,80 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
Run.tg do
|
4
|
-
|
5
|
-
let(:v0) { graph.create_vertex }
|
6
|
-
let(:v1) { graph.create_vertex }
|
7
|
-
let(:e0) { graph.create_edge '0', v0, v1, :default }
|
8
|
-
|
9
|
-
describe '#element_type' do
|
10
|
-
context 'invalid' do
|
11
|
-
it { expect { graph.element_type(:nothing) }.to raise_error(ArgumentError) }
|
12
|
-
end
|
13
|
-
|
14
|
-
context ':vertex' do
|
15
|
-
subject { Pacer.tg.element_type(:vertex) }
|
16
|
-
it { should == :vertex }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'a vertex' do
|
20
|
-
subject { graph.element_type(v0) }
|
21
|
-
it { should == :vertex }
|
22
|
-
end
|
23
|
-
|
24
|
-
context ':edge' do
|
25
|
-
subject { graph.element_type(:edge) }
|
26
|
-
it { should == :edge }
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'an edge' do
|
30
|
-
subject { graph.element_type(e0) }
|
31
|
-
it { should == :edge }
|
32
|
-
end
|
33
|
-
|
34
|
-
context ':mixed' do
|
35
|
-
subject { graph.element_type(:mixed) }
|
36
|
-
it { should == :mixed }
|
37
|
-
end
|
38
|
-
|
39
|
-
context ':object' do
|
40
|
-
subject { graph.element_type(:object) }
|
41
|
-
it { should == :object }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#sanitize_properties' do
|
46
|
-
specify 'returns its argument' do
|
47
|
-
arg = { :a => 1 }
|
48
|
-
graph.sanitize_properties(arg).should equal(arg)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#in_vertex' do
|
53
|
-
it 'should wrap the vertex' do
|
54
|
-
v = e0.in_vertex(Tackle::SimpleMixin)
|
55
|
-
v.should == v1
|
56
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should wrap the vertex 2' do
|
60
|
-
v = e0.in_vertex([Tackle::SimpleMixin])
|
61
|
-
v.should == v1
|
62
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#out_vertex' do
|
67
|
-
it 'should wrap the vertex' do
|
68
|
-
v = e0.out_vertex(Tackle::SimpleMixin)
|
69
|
-
v.should == v0
|
70
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should wrap the vertex 2' do
|
74
|
-
v = e0.out_vertex([Tackle::SimpleMixin])
|
75
|
-
v.should == v0
|
76
|
-
v.extensions.should include(Tackle::SimpleMixin)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
4
|
+
# no special cases for TinkerGraph?
|
80
5
|
end
|
@@ -1,5 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
Run.all(:read_write) do
|
4
|
+
use_pacer_graphml_data(:read_write)
|
5
|
+
|
6
|
+
describe '#property?' do
|
7
|
+
before do
|
8
|
+
setup_data
|
9
|
+
graph.create_vertex other: 'hi'
|
10
|
+
graph.create_vertex falsy: false
|
11
|
+
graph.create_vertex zero: 0
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should filter vertices that do not have the given property' do
|
15
|
+
graph.v.count.should == 10
|
16
|
+
graph.v.property?(:name).count.should == 7
|
17
|
+
graph.v.property?(:other).count.should == 1
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should work even if the value is falsy' do
|
21
|
+
graph.v.count.should == 10
|
22
|
+
graph.v.property?(:name).count.should == 7
|
23
|
+
graph.v.property?(:zero).count.should == 1
|
24
|
+
|
25
|
+
graph.v.property?(:falsy).count.should == 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
3
30
|
Run.all(:read_only) do
|
4
31
|
use_pacer_graphml_data(:read_only)
|
5
32
|
|
@@ -30,12 +57,12 @@ Run.all(:read_only) do
|
|
30
57
|
subject { graph.v.out }
|
31
58
|
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
32
59
|
its(:count) { should == 14 }
|
33
|
-
its(:
|
60
|
+
its(:to_set) { should == graph.v.out_e.in_v.to_set }
|
34
61
|
|
35
62
|
describe '(:uses, :wrote)' do
|
36
63
|
subject { graph.v.out(:uses, :wrote) }
|
37
64
|
its(:count) { should == 9 }
|
38
|
-
it { subject.
|
65
|
+
it { subject.to_set.should == graph.v.out_e(:uses, :wrote).in_v.to_set }
|
39
66
|
end
|
40
67
|
|
41
68
|
it 'should not apply extensions to new route' do
|
@@ -47,11 +74,11 @@ Run.all(:read_only) do
|
|
47
74
|
subject { graph.v.in }
|
48
75
|
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
49
76
|
its(:count) { should == 14 }
|
50
|
-
its(:
|
77
|
+
its(:to_set) { should == graph.v.in_e.out_v.to_set }
|
51
78
|
describe '(:uses, :wrote)' do
|
52
79
|
subject { graph.v.in(:uses, :wrote) }
|
53
80
|
its(:count) { should == 9 }
|
54
|
-
it { subject.
|
81
|
+
it { subject.to_set.should == graph.v.in_e(:uses, :wrote).out_v.to_set }
|
55
82
|
end
|
56
83
|
|
57
84
|
it 'should not apply extensions to new route' do
|
@@ -97,7 +124,7 @@ Run.tg(:read_only) do
|
|
97
124
|
r = graph.v.out_e.in_v.in_e { |e| e.label == 'wrote' }.out_v
|
98
125
|
paths = r.paths
|
99
126
|
paths.first.should_not be_nil
|
100
|
-
graph.v.out_e.in_v.in_e(:wrote).out_v.paths.
|
127
|
+
graph.v.out_e.in_v.in_e(:wrote).out_v.paths.to_a.should == paths.to_a
|
101
128
|
end
|
102
129
|
end
|
103
130
|
end
|