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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b75e42193ea41f6a0d0e03133368edc9b07d264c68fb969b5c92efd2e28db32
4
- data.tar.gz: 6b26953d62482339e1762915618b0d4a3946d282004a6adaa896abb9db70e65b
3
+ metadata.gz: 2660012c78eab9ed19ce99d5ba59be689e5a25f86c3dc376d8ea11ac86290275
4
+ data.tar.gz: bbae16e2bfaa322b26e521a319ce2431d636e263ee42685706c893e02011eebf
5
5
  SHA512:
6
- metadata.gz: b61a58f2aa3daff22b1727bd0b0eb86b0d8ede3ee126d0fde39071b165f21edd6de52a7c75a4c9032c9ad460eb249a8f464950a93b7257ad49dd25e94e2e6ceb
7
- data.tar.gz: '095cd63881f370fe454e36f5dc3cb09ae8356a094d80fd60a33dcc9214add66be63338f865d4c0a1e2821dee8a58fea89c790a8b84aa20256d2a34d42b656aab'
6
+ metadata.gz: da7be812b70a047264c5950de7ee69d4b82d5ec06ec2fd5ef636b68ecad77dcb8271ab82dfe4f749571db5c11dfe00295ebf235a15605a4483db103d8bae1f3d
7
+ data.tar.gz: 1e0fe54dde3ac23a375884e8bc1a8abb0635d7bcf0a8e21864e6dde9d2a144549612f119cfd6e089f2a6c8a2e51fe7bd76f6c1db753b00a8fffb3602c5d0c259
@@ -1,21 +1,19 @@
1
1
  language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.0.0
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
@@ -105,8 +105,8 @@ module Build
105
105
  return self
106
106
  end
107
107
 
108
- def invoke(node, **options)
109
- child_task = @walker.call(node, **options)
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
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Build
22
22
  module Graph
23
- VERSION = "1.1.0"
23
+ VERSION = "1.2.0"
24
24
  end
25
25
  end
@@ -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 with(**state)
91
- @call_stack.with(**state) do
92
- yield
93
- end
94
- end
95
-
96
- def call(node, **state)
97
- @call_stack.with(**state) do
98
- # We try to fetch the task if it has already been invoked, otherwise we create a new task.
99
- @tasks.fetch(node) do
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.1.0
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-02-14 00:00:00.000000000 Z
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