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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29595e97b35dae140b2e1ed4c5746760a7c3a2828cbaedf067879aac9f06380b
4
- data.tar.gz: 8e43ee79b4740d6c720ebb07876abf6d6b1b397fe1062fe4e862dfa43981682d
3
+ metadata.gz: dabf6063bc0e1e603e1f57034b12b72ec64eafb426ed0974872b7942bc1b1a48
4
+ data.tar.gz: 0b6d9636f80f0416eb0ca8d67ad9d2b2ba8a666a238ae658bafd2d934df16a25
5
5
  SHA512:
6
- metadata.gz: 74caf458811484e32bd530514d586740139366cf2d1831fc90d815d7481439e8eba1051eb6a154ab363b796beb9829cf33c81351af9b349ea3bce5efbe203159
7
- data.tar.gz: 208a8afb4fccc22b8ab821787dfede32c0461a6f8d6a4efecea56b50bc2120df2e9fb4ef063eb36320358fa1b80f3393f5f75bcf6a6318962811e89b654e6ebf
6
+ metadata.gz: f909b3b2bf9a0a1c433a9b839f27200070209c46bb295c21dce9c1b7598028781887b78714dd798cf5c053b9aaf58695bb5b846dc3fc22839a81dd4766d3b9c2
7
+ data.tar.gz: f2e9aa7c715bace13a49ae5c21327dbfcc2e39667a77f12c3cc51966303a6b962f4efcc5f90f4f96b52ebf3a1b587244a0aa89dd0b6cb2758cbd984a864a9ec2
data/Gemfile CHANGED
@@ -4,6 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rake'
7
-
8
7
  gem 'rspec'
9
8
  gem 'rubocop'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- integration_workflow (0.1.0)
4
+ integration_workflow (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -46,6 +46,7 @@ GEM
46
46
 
47
47
  PLATFORMS
48
48
  arm64-darwin-22
49
+ x86_64-linux
49
50
 
50
51
  DEPENDENCIES
51
52
  integration_workflow!
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
- TODO
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
@@ -0,0 +1,14 @@
1
+ class Action
2
+ attr_reader :name, :step_name, :options
3
+
4
+ def initialize(name, step_name, options, &block)
5
+ @name = name
6
+ @step_name = step_name
7
+ @options = options
8
+ @block = block
9
+ end
10
+
11
+ def run
12
+ instance_exec(&@block)
13
+ end
14
+ end
@@ -1,5 +1,21 @@
1
- require_relative 'integration_workflow/version'
1
+ require_relative 'step'
2
+ require_relative 'action'
2
3
 
3
- module IntegrationWorkflow
4
- class Error < StandardError; end
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.0
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/integration_workflow/version.rb
43
+ - lib/step.rb
43
44
  homepage: https://github.com/kirillshevch/integration_workflow
44
45
  licenses:
45
46
  - MIT
@@ -1,3 +0,0 @@
1
- module IntegrationWorkflow
2
- VERSION = '0.1.0'
3
- end