flow_core 0.0.1 → 0.0.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/app/models/flow_core/transition.rb +1 -1
- data/app/models/flow_core/workflow.rb +58 -2
- data/lib/flow_core/version.rb +1 -1
- data/lib/flow_core/violations.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a450593fd3daee1db9bcb92693d4329b0f6153f4d4c09997a409742925e38df
|
4
|
+
data.tar.gz: 326838fdb6df30560b532e93cf65d67f7059599106aa47a9db46cb6859d6c7de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 454c961586288c08a59192a3c26bc393e58b11a20f5e91daf198e83222210b661dc4fb4c2ff6aa3679914778b45cf9ddfa292cfefed90e29b3037c1abf6e32db
|
7
|
+
data.tar.gz: 59a6189a9b1d787473d68f4e2bbcd38c7e40ec52ea336a8b6efc82899b7e9f6c271f0aeea076b22ff14d1d06114352d4d48e9d2193c6e805e29552bfadcfd6b3
|
@@ -12,7 +12,7 @@ module FlowCore
|
|
12
12
|
has_many :input_arcs, -> { where(direction: :in) },
|
13
13
|
class_name: "FlowCore::Arc", inverse_of: :transition, dependent: :delete_all
|
14
14
|
has_many :output_arcs, -> { where(direction: :out) },
|
15
|
-
class_name: "FlowCore::Arc", inverse_of: :transition, dependent: :
|
15
|
+
class_name: "FlowCore::Arc", inverse_of: :transition, dependent: :destroy
|
16
16
|
|
17
17
|
has_many :input_places, through: :input_arcs, class_name: "FlowCore::Place", source: :place
|
18
18
|
|
@@ -8,9 +8,9 @@ module FlowCore
|
|
8
8
|
|
9
9
|
has_many :instances, class_name: "FlowCore::Instance", dependent: :destroy
|
10
10
|
|
11
|
-
has_many :arcs, class_name: "FlowCore::Arc", dependent: :
|
11
|
+
has_many :arcs, class_name: "FlowCore::Arc", dependent: :destroy
|
12
12
|
has_many :places, class_name: "FlowCore::Place", dependent: :delete_all
|
13
|
-
has_many :transitions, class_name: "FlowCore::Transition", dependent: :
|
13
|
+
has_many :transitions, class_name: "FlowCore::Transition", dependent: :destroy
|
14
14
|
|
15
15
|
has_one :start_place, class_name: "FlowCore::StartPlace", dependent: :delete
|
16
16
|
has_one :end_place, class_name: "FlowCore::EndPlace", dependent: :delete
|
@@ -104,6 +104,62 @@ module FlowCore
|
|
104
104
|
update! verified: false, verified_at: nil
|
105
105
|
end
|
106
106
|
|
107
|
+
def fork
|
108
|
+
new_workflow = dup
|
109
|
+
transaction do
|
110
|
+
yield new_workflow if block_given?
|
111
|
+
new_workflow.save!
|
112
|
+
|
113
|
+
new_transitions = transitions.includes(:trigger, :callbacks).map do |t|
|
114
|
+
new_transition = t.dup
|
115
|
+
new_transition.workflow = new_workflow
|
116
|
+
new_transition.save!
|
117
|
+
|
118
|
+
if t.trigger
|
119
|
+
new_trigger = t.trigger.dup
|
120
|
+
new_trigger.workflow = new_workflow
|
121
|
+
new_trigger.transition = new_transition
|
122
|
+
new_trigger.save!
|
123
|
+
end
|
124
|
+
|
125
|
+
t.callbacks.find_each do |cb|
|
126
|
+
new_cb = cb.dup
|
127
|
+
new_cb.workflow = new_workflow
|
128
|
+
new_cb.transition = new_transition
|
129
|
+
new_cb.save!
|
130
|
+
end
|
131
|
+
|
132
|
+
[t.id, new_transition.id]
|
133
|
+
end.to_h
|
134
|
+
|
135
|
+
new_places = places.map do |p|
|
136
|
+
new_place = p.dup
|
137
|
+
new_place.workflow = new_workflow
|
138
|
+
new_place.save!
|
139
|
+
|
140
|
+
[p.id, new_place.id]
|
141
|
+
end.to_h
|
142
|
+
|
143
|
+
arcs.includes(:guards).find_each do |a|
|
144
|
+
new_arc = a.dup
|
145
|
+
new_arc.workflow = new_workflow
|
146
|
+
new_arc.place_id = new_places[a.place_id]
|
147
|
+
new_arc.transition_id = new_transitions[a.transition_id]
|
148
|
+
new_arc.save!
|
149
|
+
|
150
|
+
a.guards.find_each do |g|
|
151
|
+
new_guard = g.dup
|
152
|
+
new_guard.workflow = new_workflow
|
153
|
+
new_guard.arc = new_arc
|
154
|
+
new_guard.save!
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
new_workflow.verify!
|
159
|
+
end
|
160
|
+
new_workflow
|
161
|
+
end
|
162
|
+
|
107
163
|
private
|
108
164
|
|
109
165
|
def to_rgl
|
data/lib/flow_core/version.rb
CHANGED
data/lib/flow_core/violations.rb
CHANGED
@@ -177,7 +177,7 @@ module FlowCore
|
|
177
177
|
name = records[record_key][:name]
|
178
178
|
|
179
179
|
defaults = [:"flow_core.violations.format"]
|
180
|
-
defaults << "
|
180
|
+
defaults << "%<name>s %<message>s"
|
181
181
|
|
182
182
|
I18n.t(defaults.shift,
|
183
183
|
default: defaults, model: model, model_name: model_name, id: id, name: name, message: message)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flow_core
|
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
|
- jasl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|