trailblazer-activity 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c94f3dbe368043f005ec5d68fc099246c8f302dd6e1b366989b321665d5f2b98
4
- data.tar.gz: 28f0b58b9d2de3b7adffd543860baed3e47eb25945161cbe7cc5f45a8f907abd
3
+ metadata.gz: e3223f3eba8cc3fecb792e693dbba7da7f2941a3703b953ccc61c5044916ae5f
4
+ data.tar.gz: e449258dd404bfeb40516f00b44548fdae0cb59af9b7fc4695c02c649fa71bf8
5
5
  SHA512:
6
- metadata.gz: 78eaabeff700dd6b22ff61efe8efe993287875c02e7a80197ca6880c435bba2732d61ebaa41acc4da3737ad556ae669b8dc03f6dad445394486e7a1298d62569
7
- data.tar.gz: '08b7cbeea9a42fc99a8d38f95439d6e265f0fe4051ccfa8e95a18f18c117e34bf6ae2824e07a8eb139db32e4559bd094c30d621e1fb82cc2c8e80916e7c6ee88'
6
+ metadata.gz: 3bc812315aeff872392b12b9c7094ad851c0192f3cf340d822d4c460309574737aaabb93eb192b1e130075b711cf2b548942fe7a2cad5a1ef860b4d31b78dbde
7
+ data.tar.gz: 88361f9bc83de278ea1e144276d8167c9b04f82605209ef240877e33900dc8c9480954c092a55fc1e57f516a03bbb81b8499c4488701e95b54f64343a684fc55
@@ -1,10 +1,12 @@
1
- sudo: false
2
1
  language: ruby
3
- rvm:
4
- - 2.6.0
5
- - 2.5.1
6
- - 2.4.4
7
- # - 2.3.7
8
- # - 2.2.10
9
- # - 2.1.10
10
2
  before_install: gem install bundler
3
+ cache: bundler
4
+ rvm:
5
+ - ruby-head
6
+ - 2.7
7
+ - 2.6
8
+ - 2.5
9
+ - 2.4
10
+ jobs:
11
+ allow_failures:
12
+ - rvm: ruby-head
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.11.0
2
+
3
+ * Support for Ruby 2.7. All warnings are gone.
4
+
1
5
  # 0.10.1
2
6
 
3
7
  * Update IllegalSignalError exception for more clarity
data/Gemfile CHANGED
@@ -6,8 +6,5 @@ gemspec
6
6
  gem "benchmark-ips"
7
7
  gem "minitest-line"
8
8
 
9
- gem "rubocop", require: false
10
-
11
9
  # gem "trailblazer-context", path: "../trailblazer-context"
12
10
  # gem "trailblazer-developer", path: "../trailblazer-developer"
13
- # gem "trailblazer-developer", github: "trailblazer/trailblazer-developer", branch: "exception-tracing"
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2018 Trailblazer GmbH
1
+ Copyright (c) 2018-2020 Trailblazer GmbH
2
2
 
3
3
  Trailblazer is an Open Source project licensed under the terms of
4
4
  the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
data/Rakefile CHANGED
@@ -1,13 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
- require "rubocop/rake_task"
4
3
 
5
4
  Rake::TestTask.new(:test) do |t|
6
5
  t.libs << "test"
7
6
  t.libs << "lib"
8
- t.test_files = FileList["**/*_test.rb"] - FileList["test/docs/*"] + ["test/docs/activity_test.rb"]
7
+ t.test_files = FileList["test/**/*_test.rb"] - FileList["test/docs/*"] + ["test/docs/activity_test.rb"]
9
8
  end
10
9
 
11
- RuboCop::RakeTask.new
12
-
13
- task :default => :test
10
+ task default: %i[test]
@@ -7,10 +7,10 @@ module Trailblazer
7
7
  @schema = schema
8
8
  end
9
9
 
10
- def call(args, circuit_options={})
10
+ def call(args, **circuit_options)
11
11
  @schema[:circuit].(
12
12
  args,
13
- circuit_options.merge(activity: self)
13
+ **circuit_options.merge(activity: self)
14
14
  )
15
15
  end
16
16
 
@@ -34,24 +34,15 @@ module Trailblazer
34
34
  end # Activity
35
35
  end
36
36
 
37
- # require "trailblazer/activity/interface"
38
37
  require "trailblazer/activity/structures"
39
38
  require "trailblazer/activity/schema"
40
- require "trailblazer/activity/schema/implementation"
41
- require "trailblazer/activity/schema/intermediate"
42
39
  require "trailblazer/activity/circuit"
43
40
  require "trailblazer/activity/config"
44
41
  require "trailblazer/activity/introspect"
45
-
46
42
  require "trailblazer/activity/task_wrap"
47
- require "trailblazer/activity/task_wrap/pipeline"
48
- require "trailblazer/activity/task_wrap/call_task"
49
- require "trailblazer/activity/task_wrap/runner"
50
- require "trailblazer/activity/task_wrap/variable_mapping"
51
- require "trailblazer/activity/task_wrap/inject"
43
+ require "trailblazer/activity/task_builder"
52
44
 
53
45
  require "trailblazer/option"
54
46
  require "trailblazer/context"
55
- require "trailblazer/activity/task_builder"
56
47
 
57
48
 
@@ -28,6 +28,7 @@ module Trailblazer
28
28
 
29
29
  return state[directive] if args.size == 1
30
30
  return state[directive][key] if state.key?(directive)
31
+
31
32
  nil
32
33
  end
33
34
  end
@@ -4,10 +4,6 @@ module Trailblazer
4
4
  # It abstracts internals about circuits and provides a convenient API to third-parties such as
5
5
  # tracing, rendering an activity, or finding particular tasks.
6
6
  module Introspect
7
- def self.Graph(*args)
8
- Graph.new(*args)
9
- end
10
-
11
7
  # TODO: order of step/fail/pass in Node would be cool to have
12
8
 
13
9
  # @private This API is still under construction.
@@ -20,13 +16,14 @@ module Trailblazer
20
16
  @configs = @schema[:nodes]
21
17
  end
22
18
 
23
- def find(id=nil, &block)
19
+ def find(id = nil, &block)
24
20
  return find_by_id(id) unless block_given?
21
+
25
22
  find_with_block(&block)
26
23
  end
27
24
 
28
- def collect(strategy: :circuit, &block)
29
- @map.keys.each_with_index.collect { |task, i| yield find_with_block { |node| node.task==task }, i }
25
+ def collect(strategy: :circuit)
26
+ @map.keys.each_with_index.collect { |task, i| yield find_with_block { |node| node.task == task }, i }
30
27
  end
31
28
 
32
29
  def stop_events
@@ -36,11 +33,11 @@ module Trailblazer
36
33
  private
37
34
 
38
35
  def find_by_id(id)
39
- node = @configs.find { |node| node.id == id } or return
36
+ node = @configs.find { |_node| _node.id == id } or return
40
37
  node_for(node)
41
38
  end
42
39
 
43
- def find_with_block(&block)
40
+ def find_with_block
44
41
  existing = @configs.find { |node| yield Node(node.task, node.id, node.outputs, node.data) } or return
45
42
 
46
43
  node_for(existing)
@@ -67,6 +64,10 @@ module Trailblazer
67
64
  end
68
65
  end
69
66
  end
70
- end #Introspect
67
+
68
+ def self.Graph(*args)
69
+ Graph.new(*args)
70
+ end
71
+ end # Introspect
71
72
  end
72
73
  end
@@ -11,3 +11,5 @@ module Trailblazer
11
11
  end # Schema
12
12
  end
13
13
  end
14
+ require "trailblazer/activity/schema/implementation"
15
+ require "trailblazer/activity/schema/intermediate"
@@ -20,7 +20,7 @@ class Trailblazer::Activity
20
20
  nodes = node_attributes(intermediate, implementation)
21
21
  outputs = outputs(intermediate.stop_task_ids, nodes)
22
22
  config = config(implementation, config: config_default)
23
- schema = Schema.new(circuit, outputs, nodes, config)
23
+ Schema.new(circuit, outputs, nodes, config)
24
24
  end
25
25
 
26
26
  # From the intermediate "template" and the actual implementation, compile a {Circuit} instance.
@@ -83,10 +83,10 @@ class Trailblazer::Activity
83
83
  config
84
84
  end
85
85
 
86
- private
86
+
87
87
 
88
88
  # Apply to any array.
89
- def self.for_semantic(outputs, semantic)
89
+ private_class_method def self.for_semantic(outputs, semantic)
90
90
  outputs.find { |out| out.semantic == semantic } or raise "`#{semantic}` not found"
91
91
  end
92
92
  end # Intermediate
@@ -2,13 +2,7 @@ module Trailblazer
2
2
  class Activity
3
3
  # Generic run-time structures that are built via the DSL.
4
4
 
5
- # Builds an {Activity::End} instance.
6
- def self.End(semantic)
7
- End.new(semantic: semantic)
8
- end
9
-
10
5
  # Any instance of subclass of End will halt the circuit's execution when hit.
11
-
12
6
  # An End event is a simple structure typically found as the last task invoked
13
7
  # in an activity. The special behavior is that it
14
8
  # a) maintains a semantic that is used to further connect that very event
@@ -18,8 +12,8 @@ module Trailblazer
18
12
  @options = options.merge(semantic: semantic)
19
13
  end
20
14
 
21
- def call(args, circuit_options)
22
- return self, args, circuit_options
15
+ def call(args, **circuit_options)
16
+ return self, args, **circuit_options
23
17
  end
24
18
 
25
19
  def to_h
@@ -27,15 +21,15 @@ module Trailblazer
27
21
  end
28
22
 
29
23
  def to_s
30
- %{#<#{self.class.name} #{@options.collect{ |k,v| "#{k}=#{v.inspect}" }.join(" ")}>}
24
+ %{#<#{self.class.name} #{@options.collect { |k, v| "#{k}=#{v.inspect}" }.join(" ")}>}
31
25
  end
32
26
 
33
- alias_method :inspect, :to_s
27
+ alias inspect to_s
34
28
  end
35
29
 
36
30
  class Start < End
37
- def call(args, circuit_options)
38
- return Activity::Right, args, circuit_options
31
+ def call(args, **circuit_options)
32
+ return Activity::Right, args, **circuit_options
39
33
  end
40
34
  end
41
35
 
@@ -53,5 +47,10 @@ module Trailblazer
53
47
  def self.Output(signal, semantic)
54
48
  Output.new(signal, semantic).freeze
55
49
  end
50
+
51
+ # Builds an {Activity::End} instance.
52
+ def self.End(semantic)
53
+ End.new(semantic: semantic)
54
+ end
56
55
  end
57
56
  end
@@ -11,7 +11,11 @@ module Trailblazer
11
11
  # Translates the return value of the user step into a valid signal.
12
12
  # Note that it passes through subclasses of {Signal}.
13
13
  def self.binary_signal_for(result, on_true, on_false)
14
- result.is_a?(Class) && result < Activity::Signal ? result : (result ? on_true : on_false)
14
+ if result.is_a?(Class) && result < Activity::Signal
15
+ result
16
+ else
17
+ result ? on_true : on_false
18
+ end
15
19
  end
16
20
 
17
21
  class Task
@@ -3,12 +3,12 @@ module Trailblazer
3
3
  #
4
4
  # Example with tracing:
5
5
  #
6
- # Call the task_wrap circuit:
7
- # |-- Start
8
- # |-- Trace.capture_args [optional]
9
- # |-- Call (call actual task) id: "task_wrap.call_task"
10
- # |-- Trace.capture_return [optional]
11
- # |-- Wrap::End
6
+ # Call the task_wrap circuit:
7
+ # |-- Start
8
+ # |-- Trace.capture_args [optional]
9
+ # |-- Call (call actual task) id: "task_wrap.call_task"
10
+ # |-- Trace.capture_return [optional]
11
+ # |-- Wrap::End
12
12
  module TaskWrap
13
13
  module_function
14
14
 
@@ -21,7 +21,7 @@ module Trailblazer
21
21
  )
22
22
 
23
23
  # signal, (ctx, flow), circuit_options =
24
- Runner.(activity, args, circuit_options)
24
+ Runner.(activity, args, **circuit_options)
25
25
  end
26
26
 
27
27
  # {:extension} API
@@ -29,7 +29,8 @@ module Trailblazer
29
29
  # Gets executed in {Intermediate.call} which also provides {config}.
30
30
 
31
31
  def initial_wrap_static(*)
32
- initial_sequence = TaskWrap::Pipeline.new([["task_wrap.call_task", TaskWrap.method(:call_task)]])
32
+ # return initial_sequence
33
+ TaskWrap::Pipeline.new([["task_wrap.call_task", TaskWrap.method(:call_task)]])
33
34
  end
34
35
 
35
36
  # Use this in your macros if you want to extend the {taskWrap}.
@@ -51,3 +52,8 @@ module Trailblazer
51
52
  end # TaskWrap
52
53
  end
53
54
  end
55
+ require "trailblazer/activity/task_wrap/pipeline"
56
+ require "trailblazer/activity/task_wrap/call_task"
57
+ require "trailblazer/activity/task_wrap/runner"
58
+ require "trailblazer/activity/task_wrap/variable_mapping"
59
+ require "trailblazer/activity/task_wrap/inject"
@@ -16,7 +16,7 @@ class Trailblazer::Activity
16
16
  Trailblazer::Context.for_circuit(ctx, {}, [original_ctx, flow_options], circuit_options) # TODO: test if Inject and :context_class work.
17
17
  end
18
18
 
19
- output = ->(new_ctx, (original_ctx, flow_options), circuit_options) { # FIXME: use Unscope
19
+ output = ->(new_ctx, (original_ctx, _flow_options), _circuit_options) { # FIXME: use Unscope
20
20
  _, mutable_data = new_ctx.decompose
21
21
 
22
22
  # we are only interested in the {mutable_data} part since the disposed part
@@ -9,7 +9,7 @@ class Trailblazer::Activity
9
9
  end
10
10
 
11
11
  def call(wrap_ctx, original_args)
12
- @sequence.each { |(id, task)| wrap_ctx, original_args = task.(wrap_ctx, original_args) }
12
+ @sequence.each { |(_id, task)| wrap_ctx, original_args = task.(wrap_ctx, original_args) }
13
13
 
14
14
  return wrap_ctx, original_args
15
15
  end
@@ -13,7 +13,7 @@ class Trailblazer::Activity
13
13
  wrap_ctx = { task: task }
14
14
 
15
15
  # this pipeline is "wrapped around" the actual `task`.
16
- task_wrap_pipeline = merge_static_with_runtime(task, circuit_options) || raise
16
+ task_wrap_pipeline = merge_static_with_runtime(task, **circuit_options) || raise
17
17
 
18
18
  # We save all original args passed into this Runner.call, because we want to return them later after this wrap
19
19
  # is finished.
@@ -28,15 +28,14 @@ class Trailblazer::Activity
28
28
  return wrap_ctx[:return_signal], wrap_ctx[:return_args]
29
29
  end
30
30
 
31
- private
32
31
 
33
32
  # Compute the task's wrap by applying alterations both static and from runtime.
34
33
  #
35
34
  # NOTE: this is for performance reasons: we could have only one hash containing everything but that'd mean
36
35
  # unnecessary computations at `call`-time since steps might not even be executed.
37
36
  # TODO: make this faster.
38
- def self.merge_static_with_runtime(task, wrap_runtime:, **circuit_options)
39
- static_wrap = TaskWrap.wrap_static_for(task, circuit_options) # find static wrap for this specific task [, or default wrap activity].
37
+ private_class_method def self.merge_static_with_runtime(task, wrap_runtime:, **circuit_options)
38
+ static_wrap = TaskWrap.wrap_static_for(task, **circuit_options) # find static wrap for this specific task [, or default wrap activity].
40
39
 
41
40
  # Apply runtime alterations.
42
41
  # Grab the additional wirings for the particular `task` from `wrap_runtime`.
@@ -61,7 +61,7 @@ module Trailblazer
61
61
  end
62
62
 
63
63
  def Cct(activity)
64
- cct = Trailblazer::Developer::Render::Circuit.(activity)
64
+ Trailblazer::Developer::Render::Circuit.(activity)
65
65
  end
66
66
 
67
67
  # TODO: Remove this once all it's references are removed
@@ -132,7 +132,7 @@ module Trailblazer
132
132
 
133
133
  inspects = semantics.collect { |semantic| %{#<struct Trailblazer::Activity::Output signal=#<Trailblazer::Activity::End semantic=#{semantic.inspect}>, semantic=#{semantic.inspect}>} }
134
134
 
135
- process.to_h[:outputs].inspect.must_equal %{[#{inspects.join(", ")}]}
135
+ assert_equal %{[#{inspects.join(", ")}]}, process.to_h[:outputs].inspect
136
136
 
137
137
  assert_circuit(process, circuit)
138
138
 
@@ -142,7 +142,7 @@ module Trailblazer
142
142
  def assert_circuit(schema, circuit)
143
143
  cct = Cct(schema)
144
144
  cct = cct.gsub("#<Trailblazer::Activity::TaskBuilder::Task user_proc=", "<*")
145
- cct.must_equal %{#{circuit}}
145
+ assert_equal %{#{circuit}}, cct
146
146
  end
147
147
  end
148
148
  end
@@ -1,7 +1,7 @@
1
1
  module Trailblazer
2
2
  module Version
3
3
  module Activity
4
- VERSION = "0.10.1"
4
+ VERSION = '0.11.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'trailblazer/activity/version'
4
4
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  end
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "trailblazer-context", ">= 0.2.0", "< 0.3.0"
20
+ spec.add_dependency "trailblazer-context", ">= 0.3.0", "< 0.4.0"
21
21
 
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "minitest", "~> 5.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-28 00:00:00.000000000 Z
11
+ date: 2020-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-context
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.0
19
+ version: 0.3.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 0.3.0
22
+ version: 0.4.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.2.0
29
+ version: 0.3.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.3.0
32
+ version: 0.4.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -94,9 +94,6 @@ extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
96
  - ".gitignore"
97
- - ".rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml"
98
- - ".rubocop.yml"
99
- - ".rubocop_todo.yml"
100
97
  - ".travis.yml"
101
98
  - CHANGES.md
102
99
  - Gemfile
@@ -142,7 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
139
  - !ruby/object:Gem::Version
143
140
  version: '0'
144
141
  requirements: []
145
- rubygems_version: 3.0.8
142
+ rubyforge_project:
143
+ rubygems_version: 2.7.3
146
144
  signing_key:
147
145
  specification_version: 4
148
146
  summary: Runtime code for Trailblazer activities.