caixanegra 0.1.1 → 0.1.2
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/README.md +2 -2
- data/app/assets/javascripts/caixanegra/designer.js +4 -4
- data/app/controllers/caixanegra/api/designer/flows_controller.rb +2 -3
- data/app/controllers/caixanegra/api/designer/units_controller.rb +14 -20
- data/app/controllers/caixanegra/api_controller.rb +1 -1
- data/app/models/caixanegra/unit.rb +9 -0
- data/lib/caixanegra/exceptions.rb +2 -0
- data/lib/caixanegra/executor.rb +8 -7
- data/lib/caixanegra/unit_helper.rb +32 -0
- data/lib/caixanegra/version.rb +1 -1
- data/lib/caixanegra.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df3d38ccee4981c27d6acb8e72bc4c40c00537c6c370cdc17581de1dc179ac3f
|
4
|
+
data.tar.gz: 4bad76dfbfb9834d19389a28f92a7b3a7a1208c9cdf230a43fc4f9faf6322fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 464c5ebbc06fa24c1f6f9261dd9e4241dff7bbfc8ccca0f067de5f289e5bda3a4e658475c8b15fa72971574748927016e5e23eed6020a0eda94580e7e85128ed
|
7
|
+
data.tar.gz: 55fcf0df7d3aac4d6e4458728cab6f3cfe874014903d47b5e4de1976290d8728cccdd28a687a748e43b5338bb6090b94596bb56fb43437ebbf203934c525717a
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ uid = Caixanegra::Manager.handler(my_flow || {})
|
|
51
51
|
You can then safely navigate to the designer.
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
link_to "Some flow", "/caixanegra/design/#{@uid}?unit_scope=optional_scope", target: :
|
54
|
+
link_to "Some flow", "/caixanegra/design/#{@uid}?unit_scope=optional_scope,another_optional_scope", target: :_blank
|
55
55
|
```
|
56
56
|
|
57
57
|
Saved changes will update the flow definition on Redis, and you must then persist them. You can get the flow definition for any specified **caixanegra** handled UID:
|
@@ -63,7 +63,7 @@ persist_flow(updated_flow) # your own persistence or transport solution. It's a
|
|
63
63
|
|
64
64
|
**NOTE:** There's currently no managed way to set callbacks on save actions from the designer. Working on it
|
65
65
|
|
66
|
-
Please, refer to [the wiki](https://github.com/sergiorribeiro/caixanegra/wiki) to get to know more about [
|
66
|
+
Please, refer to [the wiki](https://github.com/sergiorribeiro/caixanegra/wiki) to get to know more about [units](https://github.com/sergiorribeiro/caixanegra/wiki/Anatomy-of-a-unit).
|
67
67
|
|
68
68
|
# License
|
69
69
|
**caixanegra** is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -166,9 +166,9 @@ window.Caixanegra.Designer = {
|
|
166
166
|
ctx.beginPath();
|
167
167
|
ctx.moveTo(this.#drawValues.position.x + this.size.x, exit.markerY);
|
168
168
|
ctx.lineTo(this.#drawValues.position.x + this.size.x + 25, exit.markerY);
|
169
|
-
|
169
|
+
|
170
170
|
if (this.connectingExit === exit && context.mouse.move) {
|
171
|
-
ctx.lineTo(context.mouse.move.x, context.mouse.move.y);
|
171
|
+
ctx.lineTo(context.mouse.move.x + context.referential.x, context.mouse.move.y + context.referential.y);
|
172
172
|
} else if (exit.reference.target) {
|
173
173
|
const targetCenter = exit.reference.target.getCenter(context.referential);
|
174
174
|
ctx.lineTo(targetCenter.x, targetCenter.y);
|
@@ -382,10 +382,10 @@ window.Caixanegra.Designer = {
|
|
382
382
|
}
|
383
383
|
|
384
384
|
deleteUnit() {
|
385
|
-
this.removeUnit(this.selectedUnit.oid);
|
386
|
-
this.toggleDeleteConfirmation();
|
387
385
|
this.unitDetailPane.classList.remove("-open");
|
388
386
|
this.unitDebugHitsPane.classList.remove("-open");
|
387
|
+
this.removeUnit(this.selectedUnit.oid);
|
388
|
+
this.toggleDeleteConfirmation();
|
389
389
|
}
|
390
390
|
|
391
391
|
flushToConsole(entries) {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Caixanegra
|
4
|
-
module
|
4
|
+
module Api
|
5
5
|
module Designer
|
6
|
-
class FlowsController < ::Caixanegra::
|
6
|
+
class FlowsController < ::Caixanegra::ApiController
|
7
7
|
before_action :set_flow, only: %i[show debug_run]
|
8
8
|
|
9
9
|
def show
|
@@ -20,7 +20,6 @@ module Caixanegra
|
|
20
20
|
execution = Caixanegra::Executor.new(
|
21
21
|
initial_carryover: initial_carryover,
|
22
22
|
flow_definition: @flow,
|
23
|
-
unit_scope: params[:unit_scope],
|
24
23
|
debug_mode: true
|
25
24
|
).run
|
26
25
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Caixanegra
|
4
|
-
module
|
4
|
+
module Api
|
5
5
|
module Designer
|
6
|
-
class UnitsController < ::Caixanegra::
|
6
|
+
class UnitsController < ::Caixanegra::ApiController
|
7
7
|
def index
|
8
8
|
render json: units
|
9
9
|
end
|
@@ -15,26 +15,20 @@ module Caixanegra
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def units
|
18
|
-
@units ||=
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
@units ||= ::Caixanegra::UnitHelper.scoped_units(unit_scope).map do |k, v|
|
19
|
+
base = {
|
20
|
+
title: v.name,
|
21
|
+
type: v.type,
|
22
|
+
description: v.description,
|
23
|
+
class: k,
|
24
|
+
exits: v.exits&.map { |e| { name: e } },
|
25
|
+
inputs: v.inputs,
|
26
|
+
assignments: v.assignments
|
27
|
+
}
|
22
28
|
|
23
|
-
|
24
|
-
base = {
|
25
|
-
title: v.name,
|
26
|
-
type: v.type,
|
27
|
-
description: v.description,
|
28
|
-
class: k,
|
29
|
-
exits: v.exits&.map { |e| { name: e } },
|
30
|
-
inputs: v.inputs,
|
31
|
-
assignments: v.assignments
|
32
|
-
}
|
29
|
+
base[:set] = v.set if base[:set]
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
base
|
37
|
-
end
|
31
|
+
base
|
38
32
|
end
|
39
33
|
end
|
40
34
|
end
|
@@ -36,6 +36,12 @@ module Caixanegra
|
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
+
def exit_and_return
|
40
|
+
{
|
41
|
+
carry_over: @carry_over
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
39
45
|
def flow
|
40
46
|
exit_through exits.first
|
41
47
|
end
|
@@ -64,7 +70,10 @@ module Caixanegra
|
|
64
70
|
|
65
71
|
input_value = result
|
66
72
|
end
|
73
|
+
|
67
74
|
input_value.presence || @inputs[id][:default]
|
75
|
+
rescue StandardError
|
76
|
+
raise(UnitIOException.new, "Unable to fetch input '#{id}'")
|
68
77
|
end
|
69
78
|
|
70
79
|
def name
|
data/lib/caixanegra/executor.rb
CHANGED
@@ -5,7 +5,6 @@ module Caixanegra
|
|
5
5
|
def initialize(params)
|
6
6
|
@initial_carryover = params[:initial_carryover] || {}
|
7
7
|
@flow = (params[:flow_definition] || {}).deep_symbolize_keys
|
8
|
-
@unit_scope = params[:unit_scope]
|
9
8
|
@debug_mode = params[:debug_mode] == true
|
10
9
|
@execution = { history: [], steps: [] }
|
11
10
|
@storage = {}
|
@@ -113,6 +112,8 @@ module Caixanegra
|
|
113
112
|
raise exception
|
114
113
|
end
|
115
114
|
next_unit = next_unit(result)
|
115
|
+
raise(ContinuityException.new, "Unable to choose a valid exit") if next_unit.nil?
|
116
|
+
|
116
117
|
log_step_result(result, next_unit)
|
117
118
|
@execution[:steps] += feeder_steps
|
118
119
|
@step_unit = next_unit
|
@@ -143,6 +144,8 @@ module Caixanegra
|
|
143
144
|
end
|
144
145
|
|
145
146
|
def next_unit(result)
|
147
|
+
return nil if result.nil?
|
148
|
+
|
146
149
|
exit_name = result[:exit_through]
|
147
150
|
metadata = unit_metadata(@step_unit.oid)
|
148
151
|
log_console_entry "Next unit found through '#{exit_name}': '#{@step_unit.oid}'"
|
@@ -187,15 +190,13 @@ module Caixanegra
|
|
187
190
|
unit_class = scoped_units[unit_data[:class].to_sym]
|
188
191
|
inputs = unit_class.inputs
|
189
192
|
unit_class.new(unit_data[:oid], inputs, mappings, carry_over, @storage)
|
193
|
+
rescue
|
194
|
+
log_console_entry "Unable to load unit instance of type '#{unit_data[:class]}'"
|
195
|
+
nil
|
190
196
|
end
|
191
197
|
|
192
198
|
def scoped_units
|
193
|
-
@scoped_units ||=
|
194
|
-
base_units = Caixanegra.units.reject { |_, v| v.is_a? Hash }
|
195
|
-
scope_units = Caixanegra.units[@unit_scope] if @unit_scope.present?
|
196
|
-
|
197
|
-
base_units.merge(scope_units || {})
|
198
|
-
end
|
199
|
+
@scoped_units ||= UnitHelper.all_units
|
199
200
|
end
|
200
201
|
end
|
201
202
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Caixanegra
|
2
|
+
class UnitHelper
|
3
|
+
class << self
|
4
|
+
def scoped_units(scope)
|
5
|
+
all_units = {}
|
6
|
+
all_units = all_units.merge(Caixanegra.units.reject { |_, v| v.is_a? Hash })
|
7
|
+
|
8
|
+
(scope || "").split(",").each do |current_scope|
|
9
|
+
all_units = all_units.merge(Caixanegra.units[current_scope.to_sym])
|
10
|
+
end
|
11
|
+
|
12
|
+
all_units
|
13
|
+
end
|
14
|
+
|
15
|
+
def all_units
|
16
|
+
all_units = {}
|
17
|
+
|
18
|
+
Caixanegra.units.each do |k, v|
|
19
|
+
if v.is_a? Hash
|
20
|
+
v.each do |ik, iv|
|
21
|
+
all_units[ik] = iv
|
22
|
+
end
|
23
|
+
else
|
24
|
+
all_units[k] = v
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
all_units
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/caixanegra/version.rb
CHANGED
data/lib/caixanegra.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caixanegra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergiorribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/caixanegra/exceptions.rb
|
73
73
|
- lib/caixanegra/executor.rb
|
74
74
|
- lib/caixanegra/manager.rb
|
75
|
+
- lib/caixanegra/unit_helper.rb
|
75
76
|
- lib/caixanegra/version.rb
|
76
77
|
- lib/tasks/caixanegra_tasks.rake
|
77
78
|
homepage: https://github.com/sergiorribeiro/caixanegra/wiki
|
@@ -86,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
87
|
requirements:
|
87
88
|
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
+
version: 2.7.5
|
90
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
92
|
requirements:
|
92
93
|
- - ">="
|