trailblazer-developer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.rubocop.yml +1 -1
- data/.travis.yml +5 -4
- data/Gemfile +3 -4
- data/Rakefile +1 -1
- data/gems.local.rb +8 -0
- data/lib/trailblazer/developer/CHANGES.md +7 -0
- data/lib/trailblazer/developer/generate.rb +59 -6
- data/lib/trailblazer/developer/render/circuit.rb +6 -0
- data/lib/trailblazer/developer/version.rb +4 -2
- data/lib/trailblazer/developer/wtf.rb +12 -7
- data/lib/trailblazer/developer.rb +1 -0
- data/trailblazer-developer.gemspec +2 -1
- metadata +18 -3
- data/.rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c162908350116143c05730ff70ef9336d826214f9a3fca7d159e5487ad4814a3
|
4
|
+
data.tar.gz: 07dc4b9adccc4a6b302f4b1382791a1b7001244b4ecb6e600dd6e67986eb13be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45b8781d48450057467840d4742c9499b7d75bc26cb7ec7afda25ea6b57adfdae01ee93383ac2680203b50f33242c725d298f639f7aac342b018c4364054ba03
|
7
|
+
data.tar.gz: 0343ef1ffdc8b5cdda41991112f968e45b80e25b5fdd30c47ffa259296b4ca56eed7209f05697fa16d91a91286c2f39d0b6ade72122d00b0b3799ac1cd0f668e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -4,9 +4,8 @@ source "https://rubygems.org"
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
# gem "trailblazer-activity", ">= 0.7.1"
|
7
|
-
gem "trailblazer-activity", path: "../trailblazer-activity"
|
8
|
-
gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
|
9
|
-
|
10
|
-
# gem "json"
|
7
|
+
# gem "trailblazer-activity", path: "../trailblazer-activity"
|
8
|
+
# gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
|
9
|
+
# gem "trailblazer-activity-dsl-linear", github: "trailblazer/trailblazer-activity-dsl-linear"
|
11
10
|
|
12
11
|
gem "representable"
|
data/Rakefile
CHANGED
data/gems.local.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in trailblazer-developer.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "trailblazer-activity", path: "../trailblazer-activity"
|
7
|
+
gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
|
8
|
+
gem "representable"
|
@@ -7,7 +7,7 @@ module Trailblazer
|
|
7
7
|
module_function
|
8
8
|
|
9
9
|
Element = Struct.new(:id, :type, :linksTo, :data, :label)
|
10
|
-
Arrow = Struct.new(:target, :label)
|
10
|
+
Arrow = Struct.new(:target, :label, :message)
|
11
11
|
|
12
12
|
module Representer
|
13
13
|
class Activity < Representable::Decorator
|
@@ -19,18 +19,33 @@ module Trailblazer
|
|
19
19
|
collection :linksTo, class: Arrow, default: [] do
|
20
20
|
property :target
|
21
21
|
property :label
|
22
|
+
property :message
|
22
23
|
end
|
23
24
|
property :data, default: {}
|
25
|
+
|
24
26
|
property :label
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def call(hash)
|
30
|
-
elements =
|
32
|
+
elements = transform_from_hash(hash)
|
33
|
+
elements = remap_ids(elements)
|
34
|
+
|
35
|
+
compute_intermediate(elements)
|
36
|
+
end
|
37
|
+
|
38
|
+
def transform_from_hash(hash)
|
39
|
+
Representer::Activity.new(OpenStruct.new).from_hash(hash).elements
|
40
|
+
end
|
41
|
+
|
42
|
+
def find_start_events(elements)
|
43
|
+
elements.find_all { |el| el.type == "Event" }
|
44
|
+
end
|
31
45
|
|
32
|
-
|
33
|
-
|
46
|
+
def compute_intermediate(elements, find_start_events: method(:find_start_events))
|
47
|
+
start_events = find_start_events.(elements)
|
48
|
+
end_events = elements.find_all { |el| el.type == "EndEventTerminate" } # DISCUSS: is it really called TERMINATE?
|
34
49
|
|
35
50
|
inter = Activity::Schema::Intermediate
|
36
51
|
|
@@ -38,11 +53,12 @@ module Trailblazer
|
|
38
53
|
wiring = Hash[wiring]
|
39
54
|
|
40
55
|
# end events need this stupid special handling
|
56
|
+
# DISCUSS: currently, the END-SEMANTIC is read from the event's label.
|
41
57
|
wiring = wiring.merge(Hash[
|
42
58
|
end_events.collect do |_end|
|
43
59
|
ref, outputs = wiring.find { |ref, _| ref.id == _end.id }
|
44
60
|
|
45
|
-
[ref, [inter.Out(semantic_for(_end.to_h), nil)]]
|
61
|
+
[ref, [inter.Out(semantic_for(_end.to_h)|| raise, nil)]] # TODO: test the raise, happens when the semantic of an End can't be distinguished. # TODO: don't extract semantic from :label but from :data.
|
46
62
|
end
|
47
63
|
])
|
48
64
|
# pp wiring
|
@@ -52,14 +68,51 @@ module Trailblazer
|
|
52
68
|
|
53
69
|
# private
|
54
70
|
|
71
|
+
|
72
|
+
|
55
73
|
# We currently use the {:label} field of an arrow to encode an output semantic.
|
56
74
|
# The {:symbol_style} part will be filtered out as semantic. Defaults to {:success}.
|
57
75
|
def semantic_for(label:nil, **)
|
58
76
|
return :success unless label
|
59
77
|
|
60
|
-
|
78
|
+
extract_semantic(label)
|
79
|
+
end
|
80
|
+
|
81
|
+
def extract_semantic(label)
|
82
|
+
m = label.match(/:([^\s][\w\?!]+)/) or return
|
83
|
+
return m[1].to_sym
|
84
|
+
end
|
85
|
+
|
86
|
+
def extract_string_id(label)
|
87
|
+
m = label.match(/"(.+)"/) or return
|
61
88
|
return m[1].to_sym
|
62
89
|
end
|
90
|
+
|
91
|
+
def extract_id(label)
|
92
|
+
extract_string_id(label) || extract_semantic(label)
|
93
|
+
end
|
94
|
+
|
95
|
+
# remap {id}
|
96
|
+
def remap_ids(elements)
|
97
|
+
map = {}
|
98
|
+
|
99
|
+
elements.collect do |el|
|
100
|
+
id = (el.label && semantic = extract_id(el.label)) ? semantic : el.id.to_sym
|
101
|
+
|
102
|
+
map[el.id] = id
|
103
|
+
|
104
|
+
el.id = id
|
105
|
+
end
|
106
|
+
|
107
|
+
# remap {linksTo}
|
108
|
+
elements.collect do |el|
|
109
|
+
el.linksTo.collect do |link|
|
110
|
+
link.target = map[link.target]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
elements
|
115
|
+
end
|
63
116
|
end
|
64
117
|
end
|
65
118
|
end
|
@@ -1,17 +1,20 @@
|
|
1
1
|
module Trailblazer::Developer
|
2
2
|
module_function
|
3
3
|
|
4
|
-
def wtf(activity, args)
|
5
|
-
Wtf.invoke(activity, args)
|
4
|
+
def wtf(activity, *args)
|
5
|
+
Wtf.invoke(activity, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
alias wtf? wtf
|
6
10
|
end
|
7
|
-
alias_method :wtf?, :wtf
|
8
11
|
|
9
12
|
module Wtf
|
10
13
|
module_function
|
11
14
|
|
12
15
|
# Run {activity} with tracing enabled and inject a mutable {Stack} instance.
|
13
16
|
# This allows to display the trace even when an exception happened
|
14
|
-
def invoke(activity, (ctx, flow_options))
|
17
|
+
def invoke(activity, (ctx, flow_options), *args)
|
15
18
|
flow_options ||= {} # Ruby sucks.
|
16
19
|
|
17
20
|
# this instance gets mutated with every step. unfortunately, there is
|
@@ -19,14 +22,14 @@ module Trailblazer::Developer
|
|
19
22
|
stack = Trailblazer::Activity::Trace::Stack.new
|
20
23
|
|
21
24
|
begin
|
22
|
-
|
25
|
+
_returned_stack, *returned = Trailblazer::Activity::Trace.invoke( activity,
|
23
26
|
[
|
24
27
|
ctx,
|
25
28
|
flow_options.merge(stack: stack)
|
26
|
-
]
|
29
|
+
],
|
30
|
+
*args
|
27
31
|
)
|
28
32
|
rescue
|
29
|
-
|
30
33
|
# DISCUSS: we shouldn't use internal knowledge of the Stack/Level API here.
|
31
34
|
closest = stack.to_a
|
32
35
|
while closest.is_a?(Trailblazer::Activity::Trace::Level) && closest = closest.last do # FIXME: deep-dive via Stack API.
|
@@ -36,6 +39,8 @@ module Trailblazer::Developer
|
|
36
39
|
|
37
40
|
handle(stack, $!, closest.task, activity, [ctx, flow_options])
|
38
41
|
end
|
42
|
+
|
43
|
+
returned # FIXME: test me
|
39
44
|
end
|
40
45
|
|
41
46
|
def exception_renderer(stack:, level:, input:, name:, closest_task:)
|
@@ -4,7 +4,7 @@ require "trailblazer/developer/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "trailblazer-developer"
|
7
|
-
spec.version = Trailblazer::Developer::VERSION
|
7
|
+
spec.version = Trailblazer::Version::Developer::VERSION
|
8
8
|
spec.authors = ["Nick Sutterer"]
|
9
9
|
spec.email = ["apotonick@gmail.com"]
|
10
10
|
|
@@ -23,5 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rubocop"
|
24
24
|
|
25
25
|
spec.add_dependency "trailblazer-activity", "~> 0.8"
|
26
|
+
spec.add_dependency "trailblazer-activity-dsl-linear"
|
26
27
|
spec.add_dependency "representable"
|
27
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-developer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-
|
11
|
+
date: 2019-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: trailblazer-activity-dsl-linear
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: representable
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,7 +116,6 @@ extensions: []
|
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
104
118
|
- ".gitignore"
|
105
|
-
- ".rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml"
|
106
119
|
- ".rubocop.yml"
|
107
120
|
- ".travis.yml"
|
108
121
|
- Gemfile
|
@@ -110,7 +123,9 @@ files:
|
|
110
123
|
- Rakefile
|
111
124
|
- bin/console
|
112
125
|
- bin/setup
|
126
|
+
- gems.local.rb
|
113
127
|
- lib/trailblazer/developer.rb
|
128
|
+
- lib/trailblazer/developer/CHANGES.md
|
114
129
|
- lib/trailblazer/developer/activity.rb
|
115
130
|
- lib/trailblazer/developer/client.rb
|
116
131
|
- lib/trailblazer/developer/generate.rb
|
@@ -1,115 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.5.0
|
3
|
-
DisplayCopNames: true
|
4
|
-
Layout/CaseIndentation:
|
5
|
-
IndentOneStep: true
|
6
|
-
Layout/FirstArrayElementLineBreak:
|
7
|
-
Enabled: true
|
8
|
-
Layout/FirstHashElementLineBreak:
|
9
|
-
Enabled: true
|
10
|
-
Layout/FirstMethodArgumentLineBreak:
|
11
|
-
Enabled: true
|
12
|
-
Layout/FirstMethodParameterLineBreak:
|
13
|
-
Enabled: true
|
14
|
-
Layout/MultilineAssignmentLayout:
|
15
|
-
Enabled: true
|
16
|
-
EnforcedStyle: same_line
|
17
|
-
Layout/SpaceInsideHashLiteralBraces:
|
18
|
-
EnforcedStyle: no_space
|
19
|
-
Metrics/LineLength:
|
20
|
-
Max: 130
|
21
|
-
Metrics/ParameterLists:
|
22
|
-
Max: 5
|
23
|
-
Naming/VariableNumber:
|
24
|
-
EnforcedStyle: snake_case
|
25
|
-
Style/AndOr:
|
26
|
-
EnforcedStyle: conditionals
|
27
|
-
Style/AutoResourceCleanup:
|
28
|
-
Enabled: true
|
29
|
-
Style/CollectionMethods:
|
30
|
-
Enabled: true
|
31
|
-
Style/Documentation:
|
32
|
-
Enabled: false
|
33
|
-
Style/EmptyLiteral:
|
34
|
-
Enabled: false
|
35
|
-
Style/EmptyMethod:
|
36
|
-
EnforcedStyle: expanded
|
37
|
-
Style/FormatStringToken:
|
38
|
-
EnforcedStyle: template
|
39
|
-
Style/ImplicitRuntimeError:
|
40
|
-
Enabled: true
|
41
|
-
Style/MethodCalledOnDoEndBlock:
|
42
|
-
Enabled: true
|
43
|
-
Style/MethodDefParentheses:
|
44
|
-
EnforcedStyle: require_parentheses
|
45
|
-
Style/MissingElse:
|
46
|
-
Enabled: true
|
47
|
-
EnforcedStyle: case
|
48
|
-
Style/NumericLiterals:
|
49
|
-
Enabled: false
|
50
|
-
Style/OptionHash:
|
51
|
-
Enabled: true
|
52
|
-
Style/PercentLiteralDelimiters:
|
53
|
-
PreferredDelimiters:
|
54
|
-
"%w": "[]"
|
55
|
-
"%W": "[]"
|
56
|
-
"%i": "[]"
|
57
|
-
"%I": "[]"
|
58
|
-
"%r": "()"
|
59
|
-
Style/ReturnNil:
|
60
|
-
Enabled: true
|
61
|
-
Style/SafeNavigation:
|
62
|
-
Enabled: false
|
63
|
-
Style/Send:
|
64
|
-
Enabled: true
|
65
|
-
Style/SignalException:
|
66
|
-
EnforcedStyle: semantic
|
67
|
-
Style/StringLiterals:
|
68
|
-
EnforcedStyle: double_quotes
|
69
|
-
Style/StringLiteralsInInterpolation:
|
70
|
-
EnforcedStyle: double_quotes
|
71
|
-
Style/StringMethods:
|
72
|
-
Enabled: true
|
73
|
-
Style/SymbolArray:
|
74
|
-
Enabled: true
|
75
|
-
# this allows in rspec to have expect { } with multiple lines
|
76
|
-
Style/BlockDelimiters:
|
77
|
-
EnforcedStyle: braces_for_chaining
|
78
|
-
Layout/EndOfLine:
|
79
|
-
Enabled: false
|
80
|
-
# don't need these checks in test folders
|
81
|
-
Metrics/ModuleLength:
|
82
|
-
Exclude:
|
83
|
-
- "spec/**/*"
|
84
|
-
- "test/**/*"
|
85
|
-
Metrics/BlockLength:
|
86
|
-
Exclude:
|
87
|
-
- "spec/**/*"
|
88
|
-
- "test/**/*"
|
89
|
-
- "*.gemspec" # definitely not in the gemspec
|
90
|
-
Metrics/MethodLength:
|
91
|
-
Max: 20
|
92
|
-
Lint/UnreachableCode:
|
93
|
-
Description: 'Unreachable code.'
|
94
|
-
Enabled: false
|
95
|
-
Lint/Void:
|
96
|
-
Enabled: false
|
97
|
-
Layout/AlignHash:
|
98
|
-
EnforcedLastArgumentHashStyle: ignore_implicit
|
99
|
-
Metrics/AbcSize:
|
100
|
-
Max: 25
|
101
|
-
Style/LambdaCall:
|
102
|
-
Enabled: false
|
103
|
-
Style/Semicolon:
|
104
|
-
Enabled: false
|
105
|
-
Naming/UncommunicativeMethodParamName:
|
106
|
-
Enabled: false
|
107
|
-
Style/ClassAndModuleChildren:
|
108
|
-
Enabled: false
|
109
|
-
Layout/LeadingCommentSpace:
|
110
|
-
Exclude:
|
111
|
-
- 'test/docs/**/*'
|
112
|
-
Layout/AlignHash:
|
113
|
-
EnforcedHashRocketStyle: table
|
114
|
-
Style/FrozenStringLiteralComment:
|
115
|
-
Enabled: false
|