trailblazer-activity 0.9.4 → 0.10.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/CHANGES.md +12 -4
- data/lib/trailblazer/activity.rb +1 -0
- data/lib/trailblazer/activity/introspect.rb +72 -0
- data/lib/trailblazer/activity/version.rb +1 -1
- data/trailblazer-activity.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7bfa65d9c33030f9512d1d465cbb47862336c4cff11be999ea64845bc8d8dff
|
|
4
|
+
data.tar.gz: a28d2c3bd407fbc5db2cf0d250e68e13f169ae62297d50c51e0507bb743d641b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64a06dd8ff913d4ad708de7bcca3e846f81333eb1c70aaf1a2de132de6ac4044cee55fb6715865fd8580989ce5f944bb4e331e3e758ab925102330bb09397cd6
|
|
7
|
+
data.tar.gz: 1e00a9ee8523d21901f7a912a02afc8e25038c13111775b367226cf792796da2edbbef6853e5a4ead885858021b92a4eb9d48e466bf94a84126956b716a3397a
|
data/CHANGES.md
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
# 0.10.0
|
|
2
|
+
|
|
3
|
+
* Require `developer` >= 0.0.7.
|
|
4
|
+
* Move `Activity::Introspect` back to this very gem.
|
|
5
|
+
* This is hopefully the last release before 2.1.0. :trollface:
|
|
6
|
+
|
|
1
7
|
# 0.9.4
|
|
2
8
|
|
|
3
|
-
Move some test helpers to `Activity::Testing` to export them to other gems
|
|
9
|
+
* Move some test helpers to `Activity::Testing` to export them to other gems
|
|
10
|
+
* Remove introspection modules, it'll also be part of the `Dev` tools now.
|
|
11
|
+
* Remove tracing modules, it'll be part of the `Dev` tools now.
|
|
4
12
|
|
|
5
13
|
# 0.9.3
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
Unreleased.
|
|
8
16
|
|
|
9
17
|
# 0.9.2
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
Unreleased.
|
|
12
20
|
|
|
13
21
|
# 0.9.1
|
|
14
22
|
|
|
15
|
-
Use `context-0.9.1`.
|
|
23
|
+
* Use `context-0.9.1`.
|
|
16
24
|
|
|
17
25
|
# 0.9.0
|
|
18
26
|
|
data/lib/trailblazer/activity.rb
CHANGED
|
@@ -41,6 +41,7 @@ require "trailblazer/activity/schema/implementation"
|
|
|
41
41
|
require "trailblazer/activity/schema/intermediate"
|
|
42
42
|
require "trailblazer/activity/circuit"
|
|
43
43
|
require "trailblazer/activity/config"
|
|
44
|
+
require "trailblazer/activity/introspect"
|
|
44
45
|
|
|
45
46
|
require "trailblazer/activity/task_wrap"
|
|
46
47
|
require "trailblazer/activity/task_wrap/pipeline"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module Trailblazer
|
|
2
|
+
class Activity
|
|
3
|
+
# The Introspect API provides inflections for `Activity` instances.
|
|
4
|
+
# It abstracts internals about circuits and provides a convenient API to third-parties such as
|
|
5
|
+
# tracing, rendering an activity, or finding particular tasks.
|
|
6
|
+
module Introspect
|
|
7
|
+
def self.Graph(*args)
|
|
8
|
+
Graph.new(*args)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# TODO: order of step/fail/pass in Node would be cool to have
|
|
12
|
+
|
|
13
|
+
# @private This API is still under construction.
|
|
14
|
+
class Graph
|
|
15
|
+
def initialize(activity)
|
|
16
|
+
@activity = activity
|
|
17
|
+
@schema = activity.to_h or raise
|
|
18
|
+
@circuit = @schema[:circuit]
|
|
19
|
+
@map = @circuit.to_h[:map]
|
|
20
|
+
@configs = @schema[:nodes]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def find(id=nil, &block)
|
|
24
|
+
return find_by_id(id) unless block_given?
|
|
25
|
+
find_with_block(&block)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def collect(strategy: :circuit, &block)
|
|
29
|
+
@map.keys.each_with_index.collect { |task, i| yield find_with_block { |node| node.task==task }, i }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def stop_events
|
|
33
|
+
@circuit.to_h[:end_events]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def find_by_id(id)
|
|
39
|
+
node = @configs.find { |node| node.id == id } or return
|
|
40
|
+
node_for(node)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def find_with_block(&block)
|
|
44
|
+
existing = @configs.find { |node| yield Node(node.task, node.id, node.outputs, node.data) } or return
|
|
45
|
+
|
|
46
|
+
node_for(existing)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def node_for(node_attributes)
|
|
50
|
+
Node(node_attributes.task, node_attributes.id, node_attributes.outputs, outgoings_for(node_attributes), node_attributes.data)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def Node(*args)
|
|
54
|
+
Node.new(*args).freeze
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Node = Struct.new(:task, :id, :outputs, :outgoings, :data)
|
|
58
|
+
Outgoing = Struct.new(:output, :task)
|
|
59
|
+
|
|
60
|
+
def outgoings_for(node)
|
|
61
|
+
outputs = node.outputs
|
|
62
|
+
connections = @map[node.task]
|
|
63
|
+
|
|
64
|
+
connections.collect do |signal, target|
|
|
65
|
+
output = outputs.find { |out| out.signal == signal }
|
|
66
|
+
Outgoing.new(output, target)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end #Introspect
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.add_development_dependency "bundler"
|
|
23
23
|
spec.add_development_dependency "minitest", "~> 5.0"
|
|
24
24
|
spec.add_development_dependency "rake"
|
|
25
|
-
spec.add_development_dependency "trailblazer-developer"
|
|
25
|
+
spec.add_development_dependency "trailblazer-developer", ">= 0.0.7"
|
|
26
26
|
|
|
27
27
|
spec.required_ruby_version = '>= 2.1.0'
|
|
28
28
|
end
|
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.
|
|
4
|
+
version: 0.10.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: 2019-09-
|
|
11
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: trailblazer-context
|
|
@@ -78,14 +78,14 @@ dependencies:
|
|
|
78
78
|
requirements:
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version:
|
|
81
|
+
version: 0.0.7
|
|
82
82
|
type: :development
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - ">="
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version:
|
|
88
|
+
version: 0.0.7
|
|
89
89
|
description:
|
|
90
90
|
email:
|
|
91
91
|
- apotonick@gmail.com
|
|
@@ -108,6 +108,7 @@ files:
|
|
|
108
108
|
- lib/trailblazer/activity.rb
|
|
109
109
|
- lib/trailblazer/activity/circuit.rb
|
|
110
110
|
- lib/trailblazer/activity/config.rb
|
|
111
|
+
- lib/trailblazer/activity/introspect.rb
|
|
111
112
|
- lib/trailblazer/activity/schema.rb
|
|
112
113
|
- lib/trailblazer/activity/schema/implementation.rb
|
|
113
114
|
- lib/trailblazer/activity/schema/intermediate.rb
|
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
142
143
|
version: '0'
|
|
143
144
|
requirements: []
|
|
144
145
|
rubyforge_project:
|
|
145
|
-
rubygems_version: 2.7.
|
|
146
|
+
rubygems_version: 2.7.6
|
|
146
147
|
signing_key:
|
|
147
148
|
specification_version: 4
|
|
148
149
|
summary: Runtime code for Trailblazer activities.
|