flow 0.3.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flow.rb +3 -3
- data/lib/flow/concerns/transaction_wrapper.rb +27 -0
- data/lib/flow/custom_matchers.rb +5 -0
- data/lib/flow/custom_matchers/define_argument.rb +19 -0
- data/lib/flow/custom_matchers/define_option.rb +26 -0
- data/lib/flow/custom_matchers/use_operations.rb +23 -0
- data/lib/flow/flow/callbacks.rb +13 -0
- data/lib/flow/flow/core.rb +24 -0
- data/lib/flow/flow/ebb.rb +28 -0
- data/lib/flow/flow/errors/state_invalid.rb +7 -0
- data/lib/flow/flow/flux.rb +55 -0
- data/lib/flow/flow/operations.rb +27 -0
- data/lib/flow/flow/revert.rb +18 -0
- data/lib/flow/flow/status.rb +28 -0
- data/lib/flow/flow/transactions.rb +14 -0
- data/lib/flow/flow/trigger.rb +38 -0
- data/lib/flow/flow_base.rb +23 -37
- data/lib/flow/operation/callbacks.rb +19 -0
- data/lib/flow/operation/error_handler.rb +24 -0
- data/lib/flow/operation/execute.rb +25 -12
- data/lib/flow/operation/failures.rb +65 -0
- data/lib/flow/operation/rewind.rb +24 -0
- data/lib/flow/operation/status.rb +28 -0
- data/lib/flow/operation/transactions.rb +14 -0
- data/lib/flow/operation_base.rb +17 -0
- data/lib/flow/shoulda_matcher_helper.rb +7 -0
- data/lib/flow/spec_helper.rb +4 -0
- data/lib/flow/state/arguments.rb +1 -1
- data/lib/flow/state/attributes.rb +1 -2
- data/lib/flow/state/callbacks.rb +1 -1
- data/lib/flow/state/core.rb +1 -1
- data/lib/flow/state/options.rb +4 -2
- data/lib/flow/state/string.rb +2 -6
- data/lib/flow/state_base.rb +2 -0
- data/lib/flow/version.rb +1 -1
- data/lib/generators/flow/USAGE +11 -0
- data/lib/generators/flow/application_flow/USAGE +9 -0
- data/lib/generators/flow/application_flow/application_flow_generator.rb +15 -0
- data/lib/generators/flow/application_flow/templates/application_flow.rb +3 -0
- data/lib/generators/flow/application_operation/USAGE +9 -0
- data/lib/generators/flow/application_operation/application_operation_generator.rb +15 -0
- data/lib/generators/flow/application_operation/templates/application_operation.rb +3 -0
- data/lib/generators/flow/application_state/USAGE +9 -0
- data/lib/generators/flow/application_state/application_state_generator.rb +15 -0
- data/lib/generators/flow/application_state/templates/application_state.rb +3 -0
- data/lib/generators/flow/flow_generator.rb +18 -0
- data/lib/generators/flow/install/USAGE +13 -0
- data/lib/generators/flow/install/install_generator.rb +13 -0
- data/lib/generators/flow/operation/USAGE +9 -0
- data/lib/generators/flow/operation/operation_generator.rb +15 -0
- data/lib/generators/flow/operation/templates/operation.rb.erb +7 -0
- data/lib/generators/flow/state/USAGE +9 -0
- data/lib/generators/flow/state/state_generator.rb +15 -0
- data/lib/generators/flow/state/templates/state.rb.erb +8 -0
- data/lib/generators/flow/templates/flow.rb.erb +5 -0
- data/lib/generators/rspec/application_flow/USAGE +8 -0
- data/lib/generators/rspec/application_flow/application_flow_generator.rb +13 -0
- data/lib/generators/rspec/application_flow/templates/application_flow_spec.rb +7 -0
- data/lib/generators/rspec/application_operation/USAGE +8 -0
- data/lib/generators/rspec/application_operation/application_operation_generator.rb +13 -0
- data/lib/generators/rspec/application_operation/templates/application_operation_spec.rb +11 -0
- data/lib/generators/rspec/application_state/USAGE +8 -0
- data/lib/generators/rspec/application_state/application_state_generator.rb +13 -0
- data/lib/generators/rspec/application_state/templates/application_state_spec.rb +7 -0
- data/lib/generators/rspec/flow/USAGE +8 -0
- data/lib/generators/rspec/flow/flow_generator.rb +13 -0
- data/lib/generators/rspec/flow/templates/flow_spec.rb.erb +14 -0
- data/lib/generators/rspec/operation/USAGE +8 -0
- data/lib/generators/rspec/operation/operation_generator.rb +13 -0
- data/lib/generators/rspec/operation/templates/operation_spec.rb.erb +24 -0
- data/lib/generators/rspec/state/USAGE +8 -0
- data/lib/generators/rspec/state/state_generator.rb +13 -0
- data/lib/generators/rspec/state/templates/state_spec.rb.erb +18 -0
- metadata +93 -4
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flow
|
4
|
+
module Generators
|
5
|
+
class ApplicationOperationGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
hook_for :test_framework
|
9
|
+
|
10
|
+
def create_application_operation
|
11
|
+
template "application_operation.rb", File.join("app/operations/application_operation.rb")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flow
|
4
|
+
module Generators
|
5
|
+
class ApplicationStateGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
hook_for :test_framework
|
9
|
+
|
10
|
+
def create_application_state
|
11
|
+
template "application_state.rb", File.join("app/states/application_state.rb")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flow
|
4
|
+
module Generators
|
5
|
+
class FlowGenerator < Rails::Generators::NamedBase
|
6
|
+
class_option :state, type: :boolean, default: true
|
7
|
+
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
9
|
+
|
10
|
+
hook_for :state, as: "flow:state"
|
11
|
+
hook_for :test_framework
|
12
|
+
|
13
|
+
def create_application_flow
|
14
|
+
template "flow.rb.erb", File.join("app/flows/", class_path, "#{file_name}_flow.rb")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Description:
|
2
|
+
Creates ApplicationFlow, ApplicationOperation, and ApplicationState with tests.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
`rails generate flow:install`
|
6
|
+
|
7
|
+
Generates:
|
8
|
+
Flow: app/flows/application_flow.rb
|
9
|
+
Operation: app/operations/application_operation.rb
|
10
|
+
State: app/states/application_state.rb
|
11
|
+
Test: spec/flows/application_flow_spec.rb
|
12
|
+
Test: spec/operations/application_operation_spec.rb
|
13
|
+
Test: spec/states/application_state_spec.rb
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flow
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
def run_other_generators
|
7
|
+
generate "flow:application_flow"
|
8
|
+
generate "flow:application_operation"
|
9
|
+
generate "flow:application_state"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flow
|
4
|
+
module Generators
|
5
|
+
class OperationGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
hook_for :test_framework
|
9
|
+
|
10
|
+
def create_application_state
|
11
|
+
template "operation.rb.erb", File.join("app/operations/", class_path, "#{file_name}.rb")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flow
|
4
|
+
module Generators
|
5
|
+
class StateGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
hook_for :test_framework
|
9
|
+
|
10
|
+
def create_application_state
|
11
|
+
template "state.rb.erb", File.join("app/states/", class_path, "#{file_name}_state.rb")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= class_name %>State < ApplicationState
|
4
|
+
# argument :required_input
|
5
|
+
# option :optional_input
|
6
|
+
# option :option_with_default, default: :default_static_value
|
7
|
+
# option(:option_with_default_from_block) { required_input.default_dynamic_value }
|
8
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspec
|
4
|
+
module Generators
|
5
|
+
class ApplicationFlowGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_spec_file
|
9
|
+
template "application_flow_spec.rb", File.join("spec/flows/application_flow_spec.rb")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspec
|
4
|
+
module Generators
|
5
|
+
class ApplicationOperationGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_spec_file
|
9
|
+
template "application_operation_spec.rb", File.join("spec/operations/application_operation_spec.rb")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspec
|
4
|
+
module Generators
|
5
|
+
class ApplicationStateGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_spec_file
|
9
|
+
template "application_state_spec.rb", File.join("spec/states/application_state_spec.rb")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspec
|
4
|
+
module Generators
|
5
|
+
class FlowGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_spec_file
|
9
|
+
template "flow_spec.rb.erb", File.join("spec/flows/", class_path, "#{file_name}_flow_spec.rb")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
|
5
|
+
RSpec.describe <%= class_name %>Flow, type: :flow do
|
6
|
+
subject(:flow) { described_class.new(**input) }
|
7
|
+
|
8
|
+
let(:input) do
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
|
12
|
+
it { is_expected.to inherit_from ApplicationFlow }
|
13
|
+
# it { is_expected.to use_operations ExampleOperation }
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspec
|
4
|
+
module Generators
|
5
|
+
class OperationGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_spec_file
|
9
|
+
template "operation_spec.rb.erb", File.join("spec/operations/", class_path, "#{file_name}_spec.rb")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
|
5
|
+
RSpec.describe <%= class_name %>, type: :operation do
|
6
|
+
subject(:operation) { described_class.new(state) }
|
7
|
+
|
8
|
+
let(:state) { example_state_class.new(**state_input) }
|
9
|
+
let(:example_state_class) do
|
10
|
+
Class.new(ApplicationState) do
|
11
|
+
# argument :foo
|
12
|
+
# option :bar
|
13
|
+
end
|
14
|
+
end
|
15
|
+
let(:state_input) do
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
it { is_expected.to inherit_from ApplicationOperation }
|
20
|
+
|
21
|
+
describe "#execute" do
|
22
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspec
|
4
|
+
module Generators
|
5
|
+
class StateGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_spec_file
|
9
|
+
template "state_spec.rb.erb", File.join("spec/states/", class_path, "#{file_name}_state_spec.rb")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
|
5
|
+
RSpec.describe <%= class_name %>State, type: :state do
|
6
|
+
subject(:state) { described_class.new(**input) }
|
7
|
+
|
8
|
+
let(:input) do
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
|
12
|
+
it { is_expected.to inherit_from ApplicationState }
|
13
|
+
# it { is_expected.to define_argument :foo }
|
14
|
+
# it { is_expected.to define_option(:foo) }
|
15
|
+
# it { is_expected.to define_option(:foo).with_default_value(:bar) }
|
16
|
+
# it { is_expected.to define_option(:foo).with_default_value_block }
|
17
|
+
# it { is_expected.to validate_presence_of ... }
|
18
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
@@ -25,7 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.2.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 5.2.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
@@ -164,6 +178,20 @@ dependencies:
|
|
164
178
|
- - ">="
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: 0.11.3
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: sqlite3
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 1.3.6
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 1.3.6
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: rspice
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,10 +231,33 @@ files:
|
|
203
231
|
- LICENSE.txt
|
204
232
|
- README.md
|
205
233
|
- lib/flow.rb
|
234
|
+
- lib/flow/concerns/transaction_wrapper.rb
|
235
|
+
- lib/flow/custom_matchers.rb
|
236
|
+
- lib/flow/custom_matchers/define_argument.rb
|
237
|
+
- lib/flow/custom_matchers/define_option.rb
|
238
|
+
- lib/flow/custom_matchers/use_operations.rb
|
239
|
+
- lib/flow/flow/callbacks.rb
|
240
|
+
- lib/flow/flow/core.rb
|
241
|
+
- lib/flow/flow/ebb.rb
|
242
|
+
- lib/flow/flow/errors/state_invalid.rb
|
243
|
+
- lib/flow/flow/flux.rb
|
244
|
+
- lib/flow/flow/operations.rb
|
245
|
+
- lib/flow/flow/revert.rb
|
246
|
+
- lib/flow/flow/status.rb
|
247
|
+
- lib/flow/flow/transactions.rb
|
248
|
+
- lib/flow/flow/trigger.rb
|
206
249
|
- lib/flow/flow_base.rb
|
250
|
+
- lib/flow/operation/callbacks.rb
|
207
251
|
- lib/flow/operation/core.rb
|
252
|
+
- lib/flow/operation/error_handler.rb
|
208
253
|
- lib/flow/operation/execute.rb
|
254
|
+
- lib/flow/operation/failures.rb
|
255
|
+
- lib/flow/operation/rewind.rb
|
256
|
+
- lib/flow/operation/status.rb
|
257
|
+
- lib/flow/operation/transactions.rb
|
209
258
|
- lib/flow/operation_base.rb
|
259
|
+
- lib/flow/shoulda_matcher_helper.rb
|
260
|
+
- lib/flow/spec_helper.rb
|
210
261
|
- lib/flow/state/arguments.rb
|
211
262
|
- lib/flow/state/attributes.rb
|
212
263
|
- lib/flow/state/callbacks.rb
|
@@ -215,6 +266,44 @@ files:
|
|
215
266
|
- lib/flow/state/string.rb
|
216
267
|
- lib/flow/state_base.rb
|
217
268
|
- lib/flow/version.rb
|
269
|
+
- lib/generators/flow/USAGE
|
270
|
+
- lib/generators/flow/application_flow/USAGE
|
271
|
+
- lib/generators/flow/application_flow/application_flow_generator.rb
|
272
|
+
- lib/generators/flow/application_flow/templates/application_flow.rb
|
273
|
+
- lib/generators/flow/application_operation/USAGE
|
274
|
+
- lib/generators/flow/application_operation/application_operation_generator.rb
|
275
|
+
- lib/generators/flow/application_operation/templates/application_operation.rb
|
276
|
+
- lib/generators/flow/application_state/USAGE
|
277
|
+
- lib/generators/flow/application_state/application_state_generator.rb
|
278
|
+
- lib/generators/flow/application_state/templates/application_state.rb
|
279
|
+
- lib/generators/flow/flow_generator.rb
|
280
|
+
- lib/generators/flow/install/USAGE
|
281
|
+
- lib/generators/flow/install/install_generator.rb
|
282
|
+
- lib/generators/flow/operation/USAGE
|
283
|
+
- lib/generators/flow/operation/operation_generator.rb
|
284
|
+
- lib/generators/flow/operation/templates/operation.rb.erb
|
285
|
+
- lib/generators/flow/state/USAGE
|
286
|
+
- lib/generators/flow/state/state_generator.rb
|
287
|
+
- lib/generators/flow/state/templates/state.rb.erb
|
288
|
+
- lib/generators/flow/templates/flow.rb.erb
|
289
|
+
- lib/generators/rspec/application_flow/USAGE
|
290
|
+
- lib/generators/rspec/application_flow/application_flow_generator.rb
|
291
|
+
- lib/generators/rspec/application_flow/templates/application_flow_spec.rb
|
292
|
+
- lib/generators/rspec/application_operation/USAGE
|
293
|
+
- lib/generators/rspec/application_operation/application_operation_generator.rb
|
294
|
+
- lib/generators/rspec/application_operation/templates/application_operation_spec.rb
|
295
|
+
- lib/generators/rspec/application_state/USAGE
|
296
|
+
- lib/generators/rspec/application_state/application_state_generator.rb
|
297
|
+
- lib/generators/rspec/application_state/templates/application_state_spec.rb
|
298
|
+
- lib/generators/rspec/flow/USAGE
|
299
|
+
- lib/generators/rspec/flow/flow_generator.rb
|
300
|
+
- lib/generators/rspec/flow/templates/flow_spec.rb.erb
|
301
|
+
- lib/generators/rspec/operation/USAGE
|
302
|
+
- lib/generators/rspec/operation/operation_generator.rb
|
303
|
+
- lib/generators/rspec/operation/templates/operation_spec.rb.erb
|
304
|
+
- lib/generators/rspec/state/USAGE
|
305
|
+
- lib/generators/rspec/state/state_generator.rb
|
306
|
+
- lib/generators/rspec/state/templates/state_spec.rb.erb
|
218
307
|
homepage: http://www.freshly.com
|
219
308
|
licenses:
|
220
309
|
- MIT
|