rockflow 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/lib/generators/rockflow/install_generator.rb +9 -0
- data/lib/rockflow/flow.rb +19 -5
- data/lib/rockflow/version.rb +1 -1
- data/lib/rockflow.rb +20 -0
- data/lib/templates/rockflow.rb +15 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ae1762c75ba21ee5a1ec36364cadb752ab3bd11
|
4
|
+
data.tar.gz: 82617c7fa4a418858ce1fb91abbce792e4211eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f91f0e3da1cce9f1c79de01e6c8c2e673814265e7ad2ef1cad3877d473d6b7618062d491911ac931907e6afb57ce66984d240eb2984bf370730c04863cf99f
|
7
|
+
data.tar.gz: 1ab3a8863bdc09cce9e9a7b7d713bb5b75d963f52a63b307b6041c243a8b1f65a2e5c0ce8b520f1c6a52b2cc810ba7a9391d671a4eed681e2bb17444a1aeb24c
|
data/README.md
CHANGED
@@ -21,6 +21,15 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
$ gem install rockflow
|
23
23
|
|
24
|
+
## Getting started
|
25
|
+
Run the bundle command to install it.
|
26
|
+
After you install Rockflow and add it to your Gemfile, you need to run the generator:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
rails generate rockflow:install
|
30
|
+
```
|
31
|
+
The generator will install an initializer which describes all of Rockflow's configuration options.
|
32
|
+
|
24
33
|
## Usage
|
25
34
|
|
26
35
|
To write your own flow you need two ingredients: the **flow** and your **steps** lets start by looking at the flow.
|
@@ -76,9 +85,12 @@ So now i have defined my steps and my flow but how can i execute it? Well simple
|
|
76
85
|
|
77
86
|
```ruby
|
78
87
|
flow = AwesomeFlow.new
|
79
|
-
flow.concert! # execute all steps
|
88
|
+
flow.concert! # execute all steps and returns all steps
|
89
|
+
flow.concert # returns false or true
|
80
90
|
```
|
81
91
|
|
92
|
+
Please note that if any of your steps fail the parallel execution is interrupted and and an exception is raised.
|
93
|
+
|
82
94
|
#### Summary
|
83
95
|
Define your flow by inheriting from **RockFlow::Flow**. Inside your defined flow override the setup method and use the **rock** keyword defined by your step class. Available options for the rock method are at the moment:
|
84
96
|
- **after** which takes a StepClass or an array of step classes.
|
data/lib/rockflow/flow.rb
CHANGED
@@ -41,15 +41,29 @@ module Rockflow
|
|
41
41
|
|
42
42
|
def execute_steps
|
43
43
|
while !steps_finished?
|
44
|
-
::Parallel.each(next_free_steps,
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
::Parallel.each(next_free_steps, threads_or_processes.to_sym => Rockflow.configuration.thread_or_processes) do |step|
|
45
|
+
begin
|
46
|
+
step.execute_pre_conditions
|
47
|
+
step.it_up unless step.failed?
|
48
|
+
step.execute_post_conditions
|
49
|
+
step.finish! unless step.failed?
|
50
|
+
rescue e
|
51
|
+
raise Parallel::Break, e.message
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
@steps
|
52
56
|
end
|
53
57
|
|
58
|
+
private
|
59
|
+
|
60
|
+
def threads_or_processes
|
61
|
+
if Rockflow.configuration.use_threads
|
62
|
+
:in_threads
|
63
|
+
else
|
64
|
+
:in_processes
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
54
68
|
end
|
55
69
|
end
|
data/lib/rockflow/version.rb
CHANGED
data/lib/rockflow.rb
CHANGED
@@ -5,4 +5,24 @@ require 'rockflow/errors/post_condition'
|
|
5
5
|
require 'rockflow/errors/pre_condition'
|
6
6
|
require 'parallel'
|
7
7
|
module Rockflow
|
8
|
+
class << self
|
9
|
+
attr_accessor :configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.configure
|
13
|
+
self.configuration ||= Configuration.new
|
14
|
+
yield(configuration) if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
class Configuration
|
18
|
+
attr_accessor :use_processes
|
19
|
+
attr_accessor :use_threads
|
20
|
+
attr_accessor :thread_or_processes
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@use_processes = false
|
24
|
+
@use_threads = true
|
25
|
+
@thread_or_processes = 4
|
26
|
+
end
|
27
|
+
end
|
8
28
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Rockflow.configure do |config|
|
2
|
+
# Define if you want to use processes instead of threads.
|
3
|
+
# Please keep in mind to set the option use_threads to false if you want to use processes
|
4
|
+
# Processes are set to false by default
|
5
|
+
# config.use_processes = false
|
6
|
+
|
7
|
+
# Define if you want to use threads instead of processes.
|
8
|
+
# Please keep in mind to set the option use_processes to false if you want to use threads.
|
9
|
+
# Threads are set to true by default
|
10
|
+
# config.use_threads = true
|
11
|
+
|
12
|
+
# Set the count of threads or processes to be used by rockflow.
|
13
|
+
# The default value is 4
|
14
|
+
# config.thread_or_processes = 4
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rockflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erwin Schens
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -86,12 +86,14 @@ files:
|
|
86
86
|
- Rakefile
|
87
87
|
- bin/console
|
88
88
|
- bin/setup
|
89
|
+
- lib/generators/rockflow/install_generator.rb
|
89
90
|
- lib/rockflow.rb
|
90
91
|
- lib/rockflow/errors/post_condition.rb
|
91
92
|
- lib/rockflow/errors/pre_condition.rb
|
92
93
|
- lib/rockflow/flow.rb
|
93
94
|
- lib/rockflow/step.rb
|
94
95
|
- lib/rockflow/version.rb
|
96
|
+
- lib/templates/rockflow.rb
|
95
97
|
- rockflow.gemspec
|
96
98
|
homepage: http://qurasoft.de
|
97
99
|
licenses:
|