pacer 0.9.1.1-java → 1.0.0-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.
- 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
data/lib/pacer/support.rb
CHANGED
@@ -2,9 +2,9 @@ module Pacer
|
|
2
2
|
module Support
|
3
3
|
end
|
4
4
|
end
|
5
|
-
require 'pacer/support/iterator_mixins'
|
6
5
|
require 'pacer/support/array_list'
|
7
6
|
require 'pacer/support/enumerable'
|
8
7
|
require 'pacer/support/proc'
|
9
8
|
require 'pacer/support/hash'
|
10
9
|
require 'pacer/support/native_exception'
|
10
|
+
require 'pacer/support/nil_class'
|
data/lib/pacer/transform/cap.rb
CHANGED
@@ -26,7 +26,7 @@ module Pacer
|
|
26
26
|
def side_effect_pipe(end_pipe)
|
27
27
|
old_back = @side_effect.back
|
28
28
|
begin
|
29
|
-
empty = Pacer::Route.
|
29
|
+
empty = Pacer::Route.empty self
|
30
30
|
@side_effect.back = empty
|
31
31
|
_, side_effect_pipe = @side_effect.send :build_pipeline
|
32
32
|
side_effect_pipe.setStarts end_pipe if end_pipe
|
data/lib/pacer/transform/join.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
module Pacer
|
2
2
|
module Routes
|
3
3
|
module RouteOperations
|
4
|
+
def key(&block)
|
5
|
+
join(:key, &block)
|
6
|
+
end
|
7
|
+
|
4
8
|
def join(name = nil, options = {}, &block)
|
5
9
|
args = {
|
6
10
|
:transform => :join,
|
7
11
|
element_type: :vertex,
|
8
|
-
graph: options.fetch(:multi_graph, Pacer::MultiGraph.
|
12
|
+
graph: options.fetch(:multi_graph, Pacer::MultiGraph.blank),
|
9
13
|
from_graph: graph
|
10
14
|
}
|
11
15
|
args[:multi_graph] = options[:multi_graph] if options[:multi_graph]
|
@@ -33,12 +37,13 @@ module Pacer
|
|
33
37
|
include SideEffectPipe rescue nil # may raise exception on reload.
|
34
38
|
|
35
39
|
attr_accessor :multi_graph, :current_keys, :current_values, :join_on
|
36
|
-
attr_reader :key_expando, :key_end, :values_pipes, :from_graph
|
40
|
+
attr_reader :key_expando, :key_end, :values_pipes, :from_graph, :wrapper
|
37
41
|
|
38
42
|
def initialize(from_graph, multi_graph)
|
39
43
|
super()
|
40
44
|
@from_graph = from_graph
|
41
|
-
@
|
45
|
+
@wrapper = Pacer::Wrappers::WrapperSelector.build
|
46
|
+
@multi_graph = multi_graph || Pacer::MultiGraph.blank
|
42
47
|
@values_pipes = []
|
43
48
|
@current_keys = []
|
44
49
|
@current_values = []
|
@@ -61,31 +66,25 @@ module Pacer
|
|
61
66
|
def processNextStart
|
62
67
|
while true
|
63
68
|
if current_keys.empty?
|
64
|
-
element = starts.next
|
69
|
+
element = wrapper.new starts.next
|
65
70
|
element.graph = from_graph if element.respond_to? :graph
|
66
71
|
self.current_keys = get_keys(element)
|
67
72
|
self.current_values = get_values(element) unless current_keys.empty?
|
68
73
|
else
|
69
74
|
key = current_keys.removeFirst
|
70
75
|
if key
|
71
|
-
combined = multi_graph.
|
76
|
+
combined = multi_graph.vertex(key) || multi_graph.create_vertex(key)
|
72
77
|
else
|
73
|
-
combined = multi_graph.
|
78
|
+
combined = multi_graph.create_vertex
|
74
79
|
end
|
75
80
|
combined.join_on join_on if join_on
|
76
81
|
combined[:key] = key
|
77
82
|
current_values.each do |key, values|
|
78
|
-
combined.append_property_array key, values
|
83
|
+
combined.element.append_property_array key, values
|
79
84
|
end
|
80
85
|
return combined
|
81
86
|
end
|
82
87
|
end
|
83
|
-
rescue NativeException => e
|
84
|
-
if e.cause.getClass == Pacer::NoSuchElementException.getClass
|
85
|
-
raise e.cause
|
86
|
-
else
|
87
|
-
raise e
|
88
|
-
end
|
89
88
|
end
|
90
89
|
|
91
90
|
def get_keys(element)
|
@@ -109,8 +108,13 @@ module Pacer
|
|
109
108
|
pipe.reset
|
110
109
|
expando.add element, ArrayList.new, nil
|
111
110
|
array = pipe.next
|
112
|
-
array.
|
113
|
-
|
111
|
+
array.map do |element|
|
112
|
+
if element.is_a? Pacer::Element
|
113
|
+
element = wrapper.new element
|
114
|
+
element.graph = from_graph if element.respond_to? :graph
|
115
|
+
end
|
116
|
+
element
|
117
|
+
end
|
114
118
|
end
|
115
119
|
|
116
120
|
def prepare_aggregate_pipe(from_pipe, to_pipe)
|
@@ -178,4 +182,4 @@ module Pacer
|
|
178
182
|
end
|
179
183
|
end
|
180
184
|
end
|
181
|
-
|
185
|
+
|
data/lib/pacer/transform/map.rb
CHANGED
@@ -2,7 +2,7 @@ module Pacer
|
|
2
2
|
module Routes
|
3
3
|
module RouteOperations
|
4
4
|
def map(opts = {}, &block)
|
5
|
-
chain_route({:transform => :map, :block => block, :element_type => :object}.merge(opts))
|
5
|
+
chain_route({:transform => :map, :block => block, :element_type => :object, :extensions => []}.merge(opts))
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -14,7 +14,11 @@ module Pacer
|
|
14
14
|
protected
|
15
15
|
|
16
16
|
def attach_pipe(end_pipe)
|
17
|
-
pipe
|
17
|
+
# Must wrap based on parent pipe because the element in the block has
|
18
|
+
# not yet been affected by any of this block's transforms.
|
19
|
+
pf = Pacer::Wrappers::WrappingPipeFunction.new back || source, block
|
20
|
+
pf = Pacer::Wrappers::UnwrappingPipeFunction.new pf
|
21
|
+
pipe = com.tinkerpop.pipes.transform.TransformFunctionPipe.new pf
|
18
22
|
pipe.setStarts end_pipe if end_pipe
|
19
23
|
pipe
|
20
24
|
end
|
data/lib/pacer/transform/path.rb
CHANGED
@@ -1,36 +1,57 @@
|
|
1
1
|
module Pacer
|
2
2
|
module Core
|
3
3
|
module Route
|
4
|
-
def paths
|
5
|
-
chain_route :transform => :path, :element_type => :object
|
4
|
+
def paths(*exts)
|
5
|
+
route = chain_route :transform => :path, :element_type => :object
|
6
|
+
if exts.any?
|
7
|
+
exts = exts.map { |e| Array.wrap(e) if e }
|
8
|
+
route.map(modules: Pacer::Transform::Path::Methods) do |path|
|
9
|
+
path.zip(exts).map { |element, ext| ext ? element.add_extensions(ext) : element }
|
10
|
+
end
|
11
|
+
else
|
12
|
+
route
|
13
|
+
end
|
6
14
|
end
|
7
15
|
end
|
8
16
|
end
|
9
17
|
|
10
18
|
module Transform
|
11
19
|
module Path
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
20
|
+
module Methods
|
21
|
+
def transpose
|
22
|
+
collect { |arraylist| arraylist.to_a }.transpose
|
23
|
+
end
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
def subgraph(target_graph = nil, opts = {})
|
26
|
+
raise "Can't create a subgraph within itself." if target_graph == graph
|
27
|
+
target_graph ||= Pacer.tg
|
28
|
+
target_graph.vertex_name ||= graph.vertex_name
|
29
|
+
missing_edges = Set[]
|
30
|
+
bulk_job(nil, target_graph) do |path|
|
31
|
+
path.select { |e| e.is_a? Pacer::Vertex }.each do |vertex|
|
32
|
+
vertex.clone_into target_graph
|
33
|
+
end
|
34
|
+
path.select { |e| e.is_a? Pacer::Edge }.each do |edge|
|
35
|
+
unless edge.clone_into target_graph, ignore_missing_vertices: true
|
36
|
+
missing_edges << edge
|
37
|
+
end
|
38
|
+
end
|
26
39
|
end
|
27
|
-
|
28
|
-
edge.
|
40
|
+
if missing_edges.any?
|
41
|
+
missing_edges.to_route(graph: graph, element_type: :edge).bulk_job nil, target_graph do |edge|
|
42
|
+
edge.clone_into target_graph,
|
43
|
+
ignore_missing_vertices: opts[:ignore_missing_vertices],
|
44
|
+
show_missing_vertices: opts[:show_missing_vertices]
|
45
|
+
end
|
29
46
|
end
|
47
|
+
target_graph
|
30
48
|
end
|
31
|
-
target_graph
|
32
49
|
end
|
33
50
|
|
51
|
+
import com.tinkerpop.pipes.transform.PathPipe
|
52
|
+
|
53
|
+
include Methods
|
54
|
+
|
34
55
|
protected
|
35
56
|
|
36
57
|
def attach_pipe(end_pipe)
|
@@ -41,8 +62,11 @@ module Pacer
|
|
41
62
|
|
42
63
|
def configure_iterator(iter)
|
43
64
|
if respond_to? :graph
|
44
|
-
|
45
|
-
|
65
|
+
pipe = Pacer::Pipes::PathWrappingPipe.new(graph)
|
66
|
+
pipe.setStarts iter
|
67
|
+
pipe
|
68
|
+
else
|
69
|
+
iter
|
46
70
|
end
|
47
71
|
end
|
48
72
|
end
|
@@ -7,49 +7,77 @@ module Pacer
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
|
10
11
|
module Transform
|
11
12
|
module SortSection
|
13
|
+
# VisitsSection module provides:
|
14
|
+
# section=
|
15
|
+
# section_visitor
|
16
|
+
include Pacer::Visitors::VisitsSection
|
17
|
+
|
18
|
+
attr_accessor :block
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def attach_pipe(end_pipe)
|
23
|
+
pf = Pacer::Wrappers::WrappingPipeFunction.new self, block if block
|
24
|
+
pipe = SortSectionPipe.new(self, section_visitor, pf)
|
25
|
+
pipe.setStarts end_pipe if end_pipe
|
26
|
+
pipe
|
27
|
+
end
|
28
|
+
|
29
|
+
|
12
30
|
class SortSectionPipe < Pacer::Pipes::RubyPipe
|
13
|
-
attr_reader :
|
31
|
+
attr_reader :pf_1, :pf_2, :to_sort, :to_emit, :section
|
32
|
+
attr_reader :getPathToHere
|
14
33
|
|
15
|
-
def initialize(section,
|
34
|
+
def initialize(route, section, pipe_function)
|
16
35
|
super()
|
17
36
|
@to_emit = []
|
18
37
|
@section = section
|
19
38
|
@to_sort = []
|
39
|
+
@paths = []
|
20
40
|
if section
|
21
41
|
section.visitor = self
|
22
42
|
else
|
23
43
|
on_element nil
|
24
44
|
end
|
25
|
-
if
|
26
|
-
if
|
27
|
-
@
|
45
|
+
if pipe_function
|
46
|
+
if pipe_function.arity == 1
|
47
|
+
@pf_1 = pipe_function
|
28
48
|
section.use_on_element = false
|
29
|
-
|
30
|
-
@
|
49
|
+
else
|
50
|
+
@pf_2 = pipe_function
|
31
51
|
end
|
32
52
|
else
|
33
53
|
section.use_on_element = false
|
34
54
|
end
|
35
55
|
end
|
36
56
|
|
57
|
+
def setStarts(starts)
|
58
|
+
super
|
59
|
+
enablePath(true) if pf_2
|
60
|
+
end
|
61
|
+
|
37
62
|
def processNextStart
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
to_emit.shift
|
43
|
-
rescue NativeException => e
|
44
|
-
if e.cause.getClass == Pacer::NoSuchElementException.getClass
|
45
|
-
if to_emit.empty?
|
46
|
-
raise e.cause
|
47
|
-
else
|
48
|
-
after_element
|
49
|
-
retry
|
63
|
+
if pathEnabled
|
64
|
+
while to_emit.empty?
|
65
|
+
to_sort << [starts.next, starts.getCurrentPath]
|
50
66
|
end
|
51
67
|
else
|
52
|
-
|
68
|
+
while to_emit.empty?
|
69
|
+
to_sort << [starts.next, nil]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
raise EmptyPipe.instance if to_emit.empty?
|
73
|
+
element, @getPathToHere = to_emit.shift
|
74
|
+
element
|
75
|
+
rescue EmptyPipe, java.util.NoSuchElementException
|
76
|
+
if to_emit.empty?
|
77
|
+
raise EmptyPipe.instance
|
78
|
+
else
|
79
|
+
after_element
|
80
|
+
retry
|
53
81
|
end
|
54
82
|
end
|
55
83
|
|
@@ -59,45 +87,24 @@ module Pacer
|
|
59
87
|
|
60
88
|
def after_element
|
61
89
|
if to_sort.any?
|
62
|
-
if
|
63
|
-
sorted = to_sort.sort_by do |element|
|
64
|
-
|
90
|
+
if pf_1
|
91
|
+
sorted = to_sort.sort_by do |element, path|
|
92
|
+
pf_1.call element
|
65
93
|
end
|
66
|
-
elsif
|
67
|
-
sorted = to_sort.sort_by do |element|
|
68
|
-
|
94
|
+
elsif pf_2
|
95
|
+
sorted = to_sort.sort_by do |element, path|
|
96
|
+
pf_2.call_with_args element, @section_element, pf_2.wrap_path(path)
|
69
97
|
end
|
70
98
|
else
|
71
|
-
sorted = to_sort.
|
99
|
+
sorted = to_sort.sort_by do |element, path|
|
100
|
+
element
|
101
|
+
end
|
72
102
|
end
|
73
103
|
to_emit.concat sorted
|
74
|
-
@to_sort
|
104
|
+
@to_sort.clear
|
75
105
|
end
|
76
106
|
end
|
77
107
|
end
|
78
|
-
|
79
|
-
attr_accessor :block
|
80
|
-
attr_reader :section_name, :section_route
|
81
|
-
|
82
|
-
def section=(section)
|
83
|
-
if section.is_a? Symbol
|
84
|
-
@section_name = section
|
85
|
-
@section_route = @back.get_section_route(section)
|
86
|
-
elsif section.is_a? Pacer::Route and section.respond_to? :section_name
|
87
|
-
@section_name = section.section_name
|
88
|
-
@section_route = section
|
89
|
-
else
|
90
|
-
raise ArgumentError, "Unknown section #{ section }. Provide either a name or a route created with the #section methed."
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
protected
|
95
|
-
|
96
|
-
def attach_pipe(end_pipe)
|
97
|
-
pipe = SortSectionPipe.new(@section_route.send(:section_visitor), block)
|
98
|
-
pipe.setStarts end_pipe if end_pipe
|
99
|
-
pipe
|
100
|
-
end
|
101
108
|
end
|
102
109
|
end
|
103
110
|
end
|
data/lib/pacer/utils/tsort.rb
CHANGED
@@ -15,6 +15,11 @@ module Pacer
|
|
15
15
|
# into a route.
|
16
16
|
def dependencies(&block)
|
17
17
|
anon_mod = Module.new
|
18
|
+
class << anon_mod
|
19
|
+
def inspect
|
20
|
+
'<TSort anon mixin module>'
|
21
|
+
end
|
22
|
+
end
|
18
23
|
anon_mod.const_set :Route, TSort::Route
|
19
24
|
anon_mod.const_set :Vertex, Module.new
|
20
25
|
anon_mod::Vertex.const_set :DependenciesBlock, block
|
@@ -23,7 +28,7 @@ module Pacer
|
|
23
28
|
target.const_set :DependenciesBlock, self::DependenciesBlock
|
24
29
|
end
|
25
30
|
end
|
26
|
-
route = v
|
31
|
+
route = v.add_extensions [TSort, anon_mod]
|
27
32
|
route.tsort_anon_mod = anon_mod
|
28
33
|
route
|
29
34
|
end
|
@@ -54,7 +59,7 @@ module Pacer
|
|
54
59
|
|
55
60
|
def tsort_dependencies(tsort_anon_mod = nil)
|
56
61
|
if self.class.const_defined? :DependenciesBlock
|
57
|
-
self.class::DependenciesBlock.call(self).
|
62
|
+
self.class::DependenciesBlock.call(self).add_extensions([tsort_anon_mod])
|
58
63
|
else
|
59
64
|
self.in
|
60
65
|
end
|
data/lib/pacer/utils.rb
CHANGED
data/lib/pacer/version.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module Pacer
|
2
2
|
unless const_defined? :VERSION
|
3
|
-
VERSION = "0.
|
3
|
+
VERSION = "1.0.0"
|
4
4
|
|
5
5
|
JAR = "pacer-#{ VERSION }-standalone.jar"
|
6
6
|
JAR_PATH = "lib/#{ JAR }"
|
7
7
|
|
8
8
|
START_TIME = Time.now
|
9
9
|
|
10
|
-
BLUEPRINTS_VERSION = "1.0"
|
11
|
-
PIPES_VERSION = "0
|
10
|
+
BLUEPRINTS_VERSION = "2.1.0"
|
11
|
+
PIPES_VERSION = "2.1.0"
|
12
|
+
GREMLIN_VERSION = "2.1.0"
|
12
13
|
end
|
13
14
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Pacer
|
2
|
+
module Routes
|
3
|
+
module RouteOperations
|
4
|
+
def section(section_name = nil, visitor_target = nil)
|
5
|
+
chain_route visitor: :section, section_name: section_name, visitor_target: visitor_target
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Visitors
|
11
|
+
module Section
|
12
|
+
attr_accessor :section_name, :visitor_target
|
13
|
+
|
14
|
+
def will_visit!
|
15
|
+
@visitor_count = visitor_count + 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def section_visitor
|
19
|
+
section_visitors.pop
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def visitor_count
|
25
|
+
@visitor_count = 0 unless defined? @visitor_count
|
26
|
+
@visitor_count
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_reader :section_visitors
|
30
|
+
|
31
|
+
def attach_pipe(end_pipe)
|
32
|
+
pipe = end_pipe
|
33
|
+
@section_visitors = (1..visitor_count).map do
|
34
|
+
pipe = Pacer::Pipes::SimpleVisitorPipe.new Pacer::Wrappers::WrapperSelector.build(element_type, extensions), graph
|
35
|
+
pipe.setStarts end_pipe if end_pipe
|
36
|
+
end_pipe = pipe
|
37
|
+
end
|
38
|
+
pipe
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Pacer
|
2
|
+
module Visitors
|
3
|
+
# This module is mixed in to the route that actually refers to this section.
|
4
|
+
module VisitsSection
|
5
|
+
attr_reader :section, :section_route
|
6
|
+
|
7
|
+
def section=(section)
|
8
|
+
if section.is_a? Symbol
|
9
|
+
@section = section
|
10
|
+
@section_route = @back.get_section_route(section)
|
11
|
+
elsif section.is_a? Pacer::Route and section.respond_to? :section_name
|
12
|
+
@section = section.section_name
|
13
|
+
@section_route = section
|
14
|
+
else
|
15
|
+
raise ArgumentError, "Unknown section #{ section }. Provide either a name or a route created with the #section methed."
|
16
|
+
end
|
17
|
+
@section_route.will_visit!
|
18
|
+
@section_route
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def section_visitor
|
24
|
+
section_route.section_visitor if section_route
|
25
|
+
end
|
26
|
+
|
27
|
+
def section_visitor_target
|
28
|
+
section_route.visitor_target if section_route
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|