build-graph 1.1.0 → 1.2.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +13 -15
- data/lib/build/graph/task.rb +2 -2
- data/lib/build/graph/version.rb +1 -1
- data/lib/build/graph/walker.rb +11 -22
- metadata +2 -5
- data/lib/build/graph/call_stack.rb +0 -51
- data/spec/build/graph/call_stack_spec.rb +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2660012c78eab9ed19ce99d5ba59be689e5a25f86c3dc376d8ea11ac86290275
|
|
4
|
+
data.tar.gz: bbae16e2bfaa322b26e521a319ce2431d636e263ee42685706c893e02011eebf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da7be812b70a047264c5950de7ee69d4b82d5ec06ec2fd5ef636b68ecad77dcb8271ab82dfe4f749571db5c11dfe00295ebf235a15605a4483db103d8bae1f3d
|
|
7
|
+
data.tar.gz: 1e0fe54dde3ac23a375884e8bc1a8abb0635d7bcf0a8e21864e6dde9d2a144549612f119cfd6e089f2a6c8a2e51fe7bd76f6c1db753b00a8fffb3602c5d0c259
|
data/.travis.yml
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- 2.1.8
|
|
6
|
-
- 2.2.4
|
|
7
|
-
- 2.3.0
|
|
8
|
-
- ruby-head
|
|
9
|
-
- rbx-2
|
|
10
|
-
env: COVERAGE=true
|
|
11
|
-
matrix:
|
|
12
|
-
fast_finish: true
|
|
13
|
-
allow_failures:
|
|
14
|
-
- rvm: ruby-head
|
|
15
|
-
- rvm: "rbx-2"
|
|
2
|
+
dist: xenial
|
|
3
|
+
cache: bundler
|
|
4
|
+
|
|
16
5
|
addons:
|
|
17
6
|
apt:
|
|
18
7
|
sources:
|
|
19
8
|
- ubuntu-toolchain-r-test
|
|
20
9
|
packages:
|
|
21
|
-
- libstdc++-4.8-dev
|
|
10
|
+
- libstdc++-4.8-dev
|
|
11
|
+
|
|
12
|
+
matrix:
|
|
13
|
+
include:
|
|
14
|
+
- rvm: 2.3
|
|
15
|
+
- rvm: 2.4
|
|
16
|
+
- rvm: 2.5
|
|
17
|
+
- rvm: 2.6
|
|
18
|
+
- rvm: 2.6
|
|
19
|
+
env: COVERAGE=BriefSummary,Coveralls
|
data/lib/build/graph/task.rb
CHANGED
|
@@ -105,8 +105,8 @@ module Build
|
|
|
105
105
|
return self
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
def invoke(node
|
|
109
|
-
child_task = @walker.call(node,
|
|
108
|
+
def invoke(node)
|
|
109
|
+
child_task = @walker.call(node, self)
|
|
110
110
|
|
|
111
111
|
raise ArgumentError.new("Invalid child task") unless child_task
|
|
112
112
|
|
data/lib/build/graph/version.rb
CHANGED
data/lib/build/graph/walker.rb
CHANGED
|
@@ -25,14 +25,12 @@ require_relative 'task'
|
|
|
25
25
|
require_relative 'node'
|
|
26
26
|
require_relative 'edge'
|
|
27
27
|
|
|
28
|
-
require_relative 'call_stack'
|
|
29
|
-
|
|
30
28
|
module Build
|
|
31
29
|
module Graph
|
|
32
30
|
# A walker walks over a graph and applies a task to each node.
|
|
33
31
|
class Walker
|
|
34
32
|
def self.for(task_class, *args, **options)
|
|
35
|
-
self.new(**options) do |walker, node|
|
|
33
|
+
self.new(**options) do |walker, node, parent_task = nil|
|
|
36
34
|
task = task_class.new(walker, node, *args)
|
|
37
35
|
|
|
38
36
|
task.visit do
|
|
@@ -58,8 +56,6 @@ module Build
|
|
|
58
56
|
|
|
59
57
|
@logger = logger || Logger.new(nil)
|
|
60
58
|
@monitor = Files::Monitor.new(logger: @logger)
|
|
61
|
-
|
|
62
|
-
@call_stack = CallStack.new
|
|
63
59
|
end
|
|
64
60
|
|
|
65
61
|
# Primarily for debugging from within Task
|
|
@@ -87,23 +83,16 @@ module Build
|
|
|
87
83
|
end
|
|
88
84
|
end
|
|
89
85
|
|
|
90
|
-
def
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
#
|
|
99
|
-
@tasks
|
|
100
|
-
@logger.debug{"Update: #{node}"}
|
|
101
|
-
|
|
102
|
-
@update.call(self, node, @call_stack.last)
|
|
103
|
-
|
|
104
|
-
# This should now be defined:
|
|
105
|
-
return @tasks[node]
|
|
106
|
-
end
|
|
86
|
+
def call(node, parent_task = nil)
|
|
87
|
+
# We try to fetch the task if it has already been invoked, otherwise we create a new task.
|
|
88
|
+
@tasks.fetch(node) do
|
|
89
|
+
@logger.debug{"Update: #{node} #{parent_task.inspect}"}
|
|
90
|
+
|
|
91
|
+
# This method should add the node
|
|
92
|
+
@update.call(self, node, parent_task)
|
|
93
|
+
|
|
94
|
+
# This should now be defined:
|
|
95
|
+
return @tasks[node]
|
|
107
96
|
end
|
|
108
97
|
end
|
|
109
98
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: build-graph
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: process-group
|
|
@@ -139,14 +139,12 @@ files:
|
|
|
139
139
|
- Rakefile
|
|
140
140
|
- build-graph.gemspec
|
|
141
141
|
- lib/build/graph.rb
|
|
142
|
-
- lib/build/graph/call_stack.rb
|
|
143
142
|
- lib/build/graph/edge.rb
|
|
144
143
|
- lib/build/graph/node.rb
|
|
145
144
|
- lib/build/graph/task.rb
|
|
146
145
|
- lib/build/graph/version.rb
|
|
147
146
|
- lib/build/graph/walker.rb
|
|
148
147
|
- spec/build/graph/build_test.rb
|
|
149
|
-
- spec/build/graph/call_stack_spec.rb
|
|
150
148
|
- spec/build/graph/edge_spec.rb
|
|
151
149
|
- spec/build/graph/graph_spec.rb
|
|
152
150
|
- spec/build/graph/inherit_spec.rb
|
|
@@ -186,7 +184,6 @@ summary: Build::Graph is a framework for build systems, with specific functional
|
|
|
186
184
|
for dealing with file based processes.
|
|
187
185
|
test_files:
|
|
188
186
|
- spec/build/graph/build_test.rb
|
|
189
|
-
- spec/build/graph/call_stack_spec.rb
|
|
190
187
|
- spec/build/graph/edge_spec.rb
|
|
191
188
|
- spec/build/graph/graph_spec.rb
|
|
192
189
|
- spec/build/graph/inherit_spec.rb
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
module Build
|
|
22
|
-
module Graph
|
|
23
|
-
# A call stack contains frames to track state during nested invocations.
|
|
24
|
-
class CallStack
|
|
25
|
-
def initialize
|
|
26
|
-
# Saves state if supplied to #call, which is useful for top level state:
|
|
27
|
-
@frames = [{}.freeze]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# All stack frames which had state associated with them.
|
|
31
|
-
attr :frames
|
|
32
|
-
|
|
33
|
-
# Yield with the given state, merged with any prior state.
|
|
34
|
-
def with(**state)
|
|
35
|
-
if state and !state.empty?
|
|
36
|
-
@frames << @frames.last.merge(state).freeze
|
|
37
|
-
yield
|
|
38
|
-
@frames.pop
|
|
39
|
-
else
|
|
40
|
-
yield
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# The current stack frame state.
|
|
45
|
-
def last
|
|
46
|
-
@frames.last
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env rspec
|
|
2
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
|
3
|
-
#
|
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
# furnished to do so, subject to the following conditions:
|
|
10
|
-
#
|
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
|
12
|
-
# all copies or substantial portions of the Software.
|
|
13
|
-
#
|
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
# THE SOFTWARE.
|
|
21
|
-
|
|
22
|
-
require 'build/graph/call_stack'
|
|
23
|
-
|
|
24
|
-
RSpec.describe Build::Graph::CallStack do
|
|
25
|
-
it "should merge state" do
|
|
26
|
-
outer_state = nil
|
|
27
|
-
inner_state = nil
|
|
28
|
-
|
|
29
|
-
subject.with(x: 10) do
|
|
30
|
-
outer_state = subject.last
|
|
31
|
-
|
|
32
|
-
subject.with(x: 20, y: 30) do
|
|
33
|
-
inner_state = subject.last
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
expect(outer_state).to include(:x)
|
|
38
|
-
expect(inner_state).to include(:x, :y)
|
|
39
|
-
end
|
|
40
|
-
end
|