trailblazer-developer 0.0.17 → 0.0.23

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: 405fb207fc4ced2cf14e18acdcc72846f0fa4ef85f010fc5d325e02c75941a06
4
- data.tar.gz: 9402b32c5be680f8e9cdbfe2e0f14dc87a5b0efe695e444ff34774ba664ee772
3
+ metadata.gz: fabb29823b1f8422ec156cc7b8fc2878aef438281457fcaf0040dccf9cd179ed
4
+ data.tar.gz: dfe238f09fcd0635268ecc47112f50c99134d0a8435fd38321cf6d6de1625da8
5
5
  SHA512:
6
- metadata.gz: f8a6f2deff06770afecfe29a13e010992277ea349aaa6682e3c5c55f2411f825665aa25c9b5a80e39390ad98a195062d0960ff7c9dfc624698611fabbd59c6a5
7
- data.tar.gz: 17f12f3422e79e0808bacbd364fb74e0dcf1b9d894490a25e3887b7266e6085523df31a4b3b06e661e6e4e470dc32044dca0a140bfd982aa5e5f2ef4d20cc058
6
+ metadata.gz: d35b2029fb0165b313ef78505a356e0a3549f49fa311e52a2f4c32ae7dbba3d976b404e2d5293bbf9e55aed83d88efd57be6f0176affcfa64af9b0b93ae5f123
7
+ data.tar.gz: 2cc21b452b8ddd2b72338c854938f548b952dd8ab4fef59e83387194bc18cab8311593d6bce747cff34f70ed92ddde73d501154882edaa6a35d372c9818a0536
@@ -0,0 +1,17 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
9
+ ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head]
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: ${{ matrix.ruby }}
16
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
17
+ - run: bundle exec rake
data/CHANGES.md CHANGED
@@ -1,3 +1,20 @@
1
+ # 0.0.23
2
+
3
+ * Remove `representable` dependency.
4
+ * Moved all editor-specific code to the `pro` gem.
5
+
6
+ # 0.0.22
7
+
8
+ * Upgrade trb-activity, trb-activity-dsl-linear and representable versions.
9
+
10
+ # 0.0.21
11
+
12
+ * Ruby 3.0 support. :sunset:
13
+
14
+ # 0.0.20
15
+
16
+ * Ruby 2.7 support
17
+
1
18
  # 0.0.17
2
19
 
3
20
  * Add `Arrow.target_lane` field in the `Generate` component.
data/Gemfile CHANGED
@@ -7,7 +7,3 @@ gemspec
7
7
  # gem "trailblazer-activity", path: "../trailblazer-activity"
8
8
  # gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
9
9
  # gem "trailblazer-activity-dsl-linear", github: "trailblazer/trailblazer-activity-dsl-linear"
10
-
11
- gem "representable"
12
- gem "faraday"
13
- gem "multi_json"
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/gems.local.rb CHANGED
@@ -6,3 +6,6 @@ gemspec
6
6
  gem "trailblazer-activity", path: "../trailblazer-activity"
7
7
  gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
8
8
  gem "representable"
9
+ gem 'pry-byebug'
10
+ gem "faraday"
11
+ gem "multi_json"
@@ -2,8 +2,8 @@ module Trailblazer
2
2
  module Developer
3
3
  module_function
4
4
 
5
- def render(activity)
6
- Render::Circuit.(activity)
5
+ def render(activity, **options)
6
+ Render::Circuit.(activity, **options)
7
7
  end
8
8
 
9
9
  module Render
@@ -28,7 +28,7 @@ module Trailblazer
28
28
 
29
29
  content = content.join("\n")
30
30
 
31
- return "\n#{content}".gsub(/0x\w+/, "0x")#.gsub(/0.\d+/, "0.")
31
+ "\n#{content}".gsub(/0x\w+/, "0x")
32
32
  end
33
33
 
34
34
  # If Ruby had pattern matching, this function wasn't necessary.
@@ -1,5 +1,3 @@
1
- require 'hirb'
2
-
3
1
  module Trailblazer
4
2
  module Developer
5
3
  module Trace
@@ -14,7 +14,8 @@ module Trailblazer::Developer
14
14
  end
15
15
 
16
16
  def tree(stack, level, tree:, renderer:, **options)
17
- tree_for(stack, level, **options.merge(tree: tree))
17
+ opts = options.merge(tree: tree)
18
+ tree_for(stack, level, **opts)
18
19
 
19
20
  nodes = tree.each_with_index.map do |task_node, position|
20
21
  renderer.(task_node: task_node, position: position, tree: tree)
@@ -27,10 +28,11 @@ module Trailblazer::Developer
27
28
  stack.each do |lvl| # always a Stack::Task[input, ..., output]
28
29
  input, output, nested = Trace::Level.input_output_nested_for_level(lvl)
29
30
 
30
- tree.push(*TreeNodes.for(level, options.merge(input: input, output: output)))
31
+ tree.push(*TreeNodes.for(level, **options.merge(input: input, output: output)))
31
32
 
32
33
  if nested.any? # nesting
33
- tree_for(nested, level + 1, **options.merge(tree: tree))
34
+ opts = options.merge(tree: tree)
35
+ tree_for(nested, level + 1, **opts)
34
36
  end
35
37
 
36
38
  tree
@@ -1,7 +1,7 @@
1
1
  module Trailblazer
2
2
  module Version
3
3
  module Developer
4
- VERSION = "0.0.17"
4
+ VERSION = "0.0.23"
5
5
  end
6
6
  end
7
7
  end
@@ -36,6 +36,9 @@ module Trailblazer::Developer
36
36
  end
37
37
 
38
38
  def fmt(line, style)
39
+ if line.is_a? Method
40
+ line = "#<Method: #<Class:>.#{line.name}>"
41
+ end
39
42
  return line unless style
40
43
  String.send(style, line)
41
44
  end
@@ -1,8 +1,8 @@
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, **circuit_options)
5
+ Wtf.invoke(activity, *args, **circuit_options)
6
6
  end
7
7
 
8
8
  class << self
@@ -16,11 +16,11 @@ module Trailblazer::Developer
16
16
  # This allows to display the trace even when an exception happened
17
17
  def invoke(activity, (ctx, flow_options), **circuit_options)
18
18
  activity, (ctx, flow_options), circuit_options = Wtf.arguments_for_trace(
19
- activity, [ctx, flow_options], circuit_options
19
+ activity, [ctx, flow_options], **circuit_options
20
20
  )
21
21
 
22
22
  _returned_stack, signal, (ctx, flow_options) = Trace.invoke(
23
- activity, [ctx, flow_options], circuit_options
23
+ activity, [ctx, flow_options], **circuit_options
24
24
  )
25
25
 
26
26
  return signal, [ctx, flow_options], circuit_options
@@ -52,7 +52,7 @@ module Trailblazer::Developer
52
52
  variables: Array( flow_options.dig(:focus_on, :variables) ),
53
53
  }
54
54
 
55
- return activity, [ ctx, flow_options ], circuit_options
55
+ [activity, [ ctx, flow_options ], circuit_options]
56
56
  end
57
57
 
58
58
  # Overring default input and output data collectors to collect/capture
@@ -61,7 +61,7 @@ module Trailblazer::Developer
61
61
  def trace_input_data_collector(wrap_config, (ctx, flow_options), circuit_options)
62
62
  data = Trace.default_input_data_collector(wrap_config, [ctx, flow_options], circuit_options)
63
63
 
64
- if Wtf.caputure_variables?(step_name: data[:task_name], **flow_options)
64
+ if Wtf.capture_variables?(step_name: data[:task_name], **flow_options)
65
65
  data[:focused_variables] = Trace::Focusable.capture_variables_from(ctx, **flow_options)
66
66
  end
67
67
 
@@ -72,7 +72,7 @@ module Trailblazer::Developer
72
72
  data = Trace.default_output_data_collector(wrap_config, [ctx, flow_options], circuit_options)
73
73
  input = flow_options[:stack].top
74
74
 
75
- if Wtf.caputure_variables?(step_name: input.data[:task_name], **flow_options)
75
+ if Wtf.capture_variables?(step_name: input.data[:task_name], **flow_options)
76
76
  data[:focused_variables] = Trace::Focusable.capture_variables_from(ctx, **flow_options)
77
77
  end
78
78
 
@@ -80,10 +80,11 @@ module Trailblazer::Developer
80
80
  end
81
81
 
82
82
  # private
83
- def caputure_variables?(step_name:, focus_on:, **)
83
+ def capture_variables?(step_name:, focus_on:, **)
84
84
  return true if focus_on[:steps].include?(step_name) # For given step
85
85
  return true if focus_on[:steps].empty? && focus_on[:variables].any? # For selected vars but all steps
86
- return false
86
+
87
+ false
87
88
  end
88
89
  end
89
90
  end
@@ -12,8 +12,5 @@ require "trailblazer/developer/trace"
12
12
  require "trailblazer/developer/trace/present"
13
13
  require "trailblazer/developer/trace/focusable"
14
14
  require "trailblazer/developer/trace/inspector"
15
- require "trailblazer/developer/generate"
16
15
  require "trailblazer/developer/render/circuit"
17
16
  require "trailblazer/developer/render/linear"
18
-
19
- # require "trailblazer/developer/client"
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["apotonick@gmail.com"]
10
10
 
11
11
  spec.summary = "Developer tools for Trailblazer."
12
- spec.description = "Developer tools for Trailblazer: debugger, tracing, visual editor integration."
12
+ spec.description = "Developer tools for Trailblazer: debugger, activity visualizer and tracing."
13
13
  spec.homepage = "http://trailblazer.to"
14
14
  spec.license = "LGPL-3.0"
15
15
 
@@ -23,8 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "minitest-line"
24
24
  spec.add_development_dependency "rake"
25
25
 
26
- spec.add_dependency "trailblazer-activity", ">= 0.11.0", "< 1.0.0"
27
- spec.add_dependency "trailblazer-activity-dsl-linear"
28
- spec.add_dependency "representable"
26
+ spec.add_dependency "trailblazer-activity", ">= 0.12.2", "< 1.0.0"
27
+ spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.4.1", "< 1.0.0"
29
28
  spec.add_dependency "hirb"
30
29
  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.17
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,7 +72,7 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.11.0
75
+ version: 0.12.2
76
76
  - - "<"
77
77
  - !ruby/object:Gem::Version
78
78
  version: 1.0.0
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 0.11.0
85
+ version: 0.12.2
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.0.0
@@ -92,28 +92,20 @@ dependencies:
92
92
  requirements:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :runtime
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: representable
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
95
+ version: 0.4.1
96
+ - - "<"
108
97
  - !ruby/object:Gem::Version
109
- version: '0'
98
+ version: 1.0.0
110
99
  type: :runtime
111
100
  prerelease: false
112
101
  version_requirements: !ruby/object:Gem::Requirement
113
102
  requirements:
114
103
  - - ">="
115
104
  - !ruby/object:Gem::Version
116
- version: '0'
105
+ version: 0.4.1
106
+ - - "<"
107
+ - !ruby/object:Gem::Version
108
+ version: 1.0.0
117
109
  - !ruby/object:Gem::Dependency
118
110
  name: hirb
119
111
  requirement: !ruby/object:Gem::Requirement
@@ -128,15 +120,15 @@ dependencies:
128
120
  - - ">="
129
121
  - !ruby/object:Gem::Version
130
122
  version: '0'
131
- description: 'Developer tools for Trailblazer: debugger, tracing, visual editor integration.'
123
+ description: 'Developer tools for Trailblazer: debugger, activity visualizer and tracing.'
132
124
  email:
133
125
  - apotonick@gmail.com
134
126
  executables: []
135
127
  extensions: []
136
128
  extra_rdoc_files: []
137
129
  files:
130
+ - ".github/workflows/ci.yml"
138
131
  - ".gitignore"
139
- - ".travis.yml"
140
132
  - CHANGES.md
141
133
  - Gemfile
142
134
  - LICENSE
@@ -146,8 +138,6 @@ files:
146
138
  - bin/setup
147
139
  - gems.local.rb
148
140
  - lib/trailblazer/developer.rb
149
- - lib/trailblazer/developer/client.rb
150
- - lib/trailblazer/developer/generate.rb
151
141
  - lib/trailblazer/developer/render/circuit.rb
152
142
  - lib/trailblazer/developer/render/linear.rb
153
143
  - lib/trailblazer/developer/trace.rb
@@ -178,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
168
  - !ruby/object:Gem::Version
179
169
  version: '0'
180
170
  requirements: []
181
- rubygems_version: 3.0.3
171
+ rubygems_version: 3.2.3
182
172
  signing_key:
183
173
  specification_version: 4
184
174
  summary: Developer tools for Trailblazer.
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6
4
- - 2.5
5
- - 2.4
6
-
7
- cache: bundler
@@ -1,95 +0,0 @@
1
- require "faraday"
2
- require "base64"
3
- require "json"
4
- require "representable/json"
5
-
6
- module Trailblazer::Developer
7
- module Client
8
- Diagram = Struct.new(:id, :body)
9
-
10
- class Diagram::Representer < Representable::Decorator
11
- include Representable::JSON
12
- property :id
13
- property :body, as: :diagram
14
- end
15
-
16
- module_function
17
-
18
- def Diagram(id, body)
19
- Diagram.new(id, body).freeze
20
- end
21
-
22
- def import(id:, query:"", **options)
23
- token = retrieve_token(**options)
24
- export_diagram(id: id, token: token, query: query, **options)
25
- end
26
-
27
- def retrieve_token(email:, api_key:, url: "/signin", **options)
28
- body = JSON.generate({email: email, api_key: api_key})
29
-
30
- response = request(token: nil, method: :get, url: url, body: body, **options)
31
- return false unless response.status == 200
32
-
33
- # token = CGI::Cookie.parse(response.headers["set-cookie"])["token"][0]
34
- JSON.parse(response.body)["token"]
35
- end
36
-
37
- def export_diagram(id:, query:, **options)
38
- response = request(body: nil, url: "/api/v1/diagrams/#{id}/export#{query}", method: :get, **options)
39
-
40
- # parse_response(response)
41
- response.body
42
- end
43
-
44
- def duplicate(id:, **options)
45
- token = retrieve_token(**options)
46
-
47
- response = request(body: nil, token: token, url: "/api/v1/diagrams/#{id}/duplicate", method: :get, **options)
48
- parse_response(response)
49
- end
50
-
51
- # DISCUSS: do we need that?
52
- def new_diagram(token:, **options)
53
- response = request(body: nil, url: "/api/v1/diagrams/new", method: :get, token: token, **options)
54
-
55
- # TODO: use Dry::Struct
56
- # TODO: handle unauthorized/errors
57
- parse_response(response)
58
- end
59
-
60
- def request(host:, url:, method:, token:, body:, **)
61
- conn = Faraday.new(url: host)
62
-
63
- conn.send(method) do |req|
64
- req.url url
65
- req.headers["Content-Type"] = "application/json"
66
- req.body = body
67
- req.headers["Authorization"] = token
68
- end
69
- end
70
-
71
- def parse_response(response)
72
- diagram = Diagram.new
73
- Diagram::Representer.new(diagram).from_json(response.body) # a parsed hash would be cooler?
74
-
75
- diagram
76
- end
77
-
78
- # TODO: remove me!
79
- def self.push(operation:, name:)
80
- xml = Trailblazer::Diagram::BPMN.to_xml(operation["__activity__"], operation["__sequence__"].map(&:id))
81
- token = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJpZCI6MywidXNlcm5hbWUiOiJhcG90b25pY2siLCJlbWFpbCI6Im5pY2tAdHJhaWxibGF6ZXIudG8ifQ." # rubocop:disable Metrics/LineLength
82
- conn = Faraday.new(url: "https://api.trb.to")
83
- response = conn.post do |req|
84
- req.url "/dev/v1/import"
85
- req.headers["Content-Type"] = "application/json"
86
- req.headers["Authorization"] = token
87
- require "base64"
88
-
89
- req.body = %({ "name": "#{name}", "xml":"#{Base64.strict_encode64(xml)}" })
90
- end
91
-
92
- puts response.status.inspect
93
- end
94
- end
95
- end
@@ -1,98 +0,0 @@
1
- require "representable/hash"
2
- require "trailblazer/activity/dsl/linear" # Railway.
3
-
4
- module Trailblazer
5
- module Developer
6
- # Computes an {Intermediate} data structure from a TRB-editor.js file.
7
- module Generate
8
- module_function
9
-
10
- Element = Struct.new(:id, :type, :linksTo, :data, :label, :parent)
11
- Arrow = Struct.new(:target, :label, :message, :target_lane)
12
-
13
- module Representer
14
- class Activity < Representable::Decorator
15
- include Representable::Hash
16
-
17
- collection :elements, class: Element do
18
- property :id
19
- property :type
20
- collection :linksTo, class: Arrow, default: ::Declarative::Variables::Append([]) do
21
- property :target
22
- property :label
23
- property :message
24
- property :target_lane
25
- end
26
- property :data, default: {}
27
-
28
- property :label
29
- property :parent # TODO: remove?
30
- end
31
- end
32
- end
33
-
34
- def call(hash)
35
- _, (ctx, _) = Activity::TaskWrap.invoke(Pipeline, hash: hash)
36
- ctx[:intermediate]
37
- end
38
-
39
- def transform_from_hash(ctx, hash:, parser: Representer::Activity, **)
40
- ctx[:elements] = parser.new(OpenStruct.new).from_hash(hash).elements
41
- end
42
-
43
- def find_start_events(ctx, elements:, **)
44
- ctx[:start_events] = elements.find_all { |el| el.type == "Event" }
45
- end
46
-
47
- def compute_intermediate(ctx, elements:, start_events:, **)
48
- end_events = elements.find_all { |el| el.type == "EndEventTerminate" } # DISCUSS: is it really called TERMINATE?
49
-
50
- inter = Activity::Schema::Intermediate
51
-
52
- wiring = elements.collect { |el|
53
- data = data_for(el)
54
-
55
- [inter.TaskRef(el.id, data), el.linksTo.collect { |arrow| inter.Out(semantic_for(**arrow.to_h), arrow.target) } ] }
56
- wiring = Hash[wiring]
57
-
58
- # end events need this stupid special handling
59
- # DISCUSS: currently, the END-SEMANTIC is read from the event's label.
60
- wiring = wiring.merge(Hash[
61
- end_events.collect do |_end|
62
- ref, = wiring.find { |ref, _| ref.id == _end.id }
63
-
64
- [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.
65
- end
66
- ])
67
- # pp wiring
68
-
69
- ctx[:intermediate] = inter.new(wiring, end_events.collect(&:id), start_events.collect(&:id))
70
- end
71
-
72
- # private
73
-
74
- def data_for(element)
75
- {type: element.type}.merge(element.data)
76
- end
77
-
78
- # We currently use the {:label} field of an arrow to encode an output semantic.
79
- # The {:symbol_style} part will be filtered out as semantic. Defaults to {:success}.
80
- def semantic_for(label:nil, **)
81
- return :success unless label
82
-
83
- extract_semantic(label)
84
- end
85
-
86
- def extract_semantic(label)
87
- label.to_sym
88
- end
89
-
90
- class Pipeline < Trailblazer::Activity::Railway
91
- step Generate.method(:transform_from_hash), id: :transform_from_hash
92
- step Generate.method(:find_start_events), id: :find_start_events
93
- step Generate.method(:compute_intermediate), id: :compute_intermediate
94
- end
95
- end
96
- end
97
- end
98
- # [Inter::Out(:success, nil)]