integration_workflow 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +2 -1
- data/README.md +43 -1
- data/lib/action.rb +14 -0
- data/lib/integration_workflow.rb +19 -3
- data/lib/step.rb +20 -0
- metadata +3 -2
- data/lib/integration_workflow/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dabf6063bc0e1e603e1f57034b12b72ec64eafb426ed0974872b7942bc1b1a48
|
4
|
+
data.tar.gz: 0b6d9636f80f0416eb0ca8d67ad9d2b2ba8a666a238ae658bafd2d934df16a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f909b3b2bf9a0a1c433a9b839f27200070209c46bb295c21dce9c1b7598028781887b78714dd798cf5c053b9aaf58695bb5b846dc3fc22839a81dd4766d3b9c2
|
7
|
+
data.tar.gz: f2e9aa7c715bace13a49ae5c21327dbfcc2e39667a77f12c3cc51966303a6b962f4efcc5f90f4f96b52ebf3a1b587244a0aa89dd0b6cb2758cbd984a864a9ec2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,9 @@ Install the gem and add it to the application's Gemfile by executing:
|
|
8
8
|
|
9
9
|
Add the `integration_workflow` gem to your application's Gemfile:
|
10
10
|
|
11
|
+
```sh
|
11
12
|
gem 'integration_workflow'
|
13
|
+
```
|
12
14
|
|
13
15
|
And then execute:
|
14
16
|
|
@@ -18,7 +20,47 @@ bundle install
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
To define a workflow with steps and actions, you can use the `step` and `action` methods, there are 2 options:
|
24
|
+
|
25
|
+
1. without options:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
workflow = IntegrationWorkflow.new do
|
29
|
+
step 'Step 1' do
|
30
|
+
action 'Action 1' do
|
31
|
+
puts "Running #{name} in #{step_name}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
step 'Step 2' do
|
36
|
+
action 'Action 1' do
|
37
|
+
puts "Running #{name} in #{step_name}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
workflow.run
|
43
|
+
```
|
44
|
+
|
45
|
+
2. with options:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
workflow = IntegrationWorkflow.new(user_id: '1') do
|
49
|
+
step 'Step 1' do
|
50
|
+
action 'Action 1' do
|
51
|
+
puts "Running #{name} in #{step_name} with user_id: #{options[:user_id]}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
step 'Step 2' do
|
56
|
+
action 'Action 1' do
|
57
|
+
puts "Running #{name} in #{step_name} with user_id: #{options[:user_id]}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
workflow.run
|
63
|
+
```
|
22
64
|
|
23
65
|
## Development
|
24
66
|
|
data/lib/action.rb
ADDED
data/lib/integration_workflow.rb
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'step'
|
2
|
+
require_relative 'action'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
class IntegrationWorkflow
|
5
|
+
attr_reader :steps, :options
|
6
|
+
|
7
|
+
def initialize(options = {}, &block)
|
8
|
+
@steps = []
|
9
|
+
@options = options
|
10
|
+
instance_exec(&block) if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
def step(name, &block)
|
14
|
+
step = Step.new(name, options, &block)
|
15
|
+
steps << step
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
steps.each(&:run)
|
20
|
+
end
|
5
21
|
end
|
data/lib/step.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class Step
|
2
|
+
attr_reader :name, :actions, :options
|
3
|
+
|
4
|
+
def initialize(name, options, &block)
|
5
|
+
@name = name
|
6
|
+
@actions = []
|
7
|
+
@options = options
|
8
|
+
instance_exec(&block) if block_given?
|
9
|
+
end
|
10
|
+
|
11
|
+
def action(name, &block)
|
12
|
+
action = Action.new(name, self.name, options, &block)
|
13
|
+
actions << action
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
# puts "Running step: #{name}"
|
18
|
+
actions.each(&:run)
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: integration_workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Shevchenko
|
@@ -38,8 +38,9 @@ files:
|
|
38
38
|
- LICENSE.txt
|
39
39
|
- README.md
|
40
40
|
- Rakefile
|
41
|
+
- lib/action.rb
|
41
42
|
- lib/integration_workflow.rb
|
42
|
-
- lib/
|
43
|
+
- lib/step.rb
|
43
44
|
homepage: https://github.com/kirillshevch/integration_workflow
|
44
45
|
licenses:
|
45
46
|
- MIT
|