rockflow 1.1.2 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97479cf2dc7550e329b306cf38bdbd8939271f0d
4
- data.tar.gz: 719a5a64754c3218af753d0417ff8db6ea91df3f
3
+ metadata.gz: 6ae1762c75ba21ee5a1ec36364cadb752ab3bd11
4
+ data.tar.gz: 82617c7fa4a418858ce1fb91abbce792e4211eb2
5
5
  SHA512:
6
- metadata.gz: 4a3a394180bd88788fc829616070f967a9f4e4e4ab27066c1429ea0743cd4ab6e01eb94538f1ee05a7bb5031008ffebec9be9c3d2c29f8d6cd2940dc9ecf0069
7
- data.tar.gz: 7c4eb50446fe6c01c4c39c00b74bf6b53b74ccdbb65384a931731c15683be1a1d1e34ae595d530b5bda36b932335f8c8e47f87edbb27961f78a9f69492cba7d4
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.
@@ -0,0 +1,9 @@
1
+ module Rockflow
2
+ class InstallGenerator < Rails::Generators::Base
3
+ source_root(File.expand_path(File.dirname(__FILE__)))
4
+
5
+ def copy_initializer
6
+ copy_file '../../templates/rockflow.rb', 'config/initializers/rockflow.rb'
7
+ end
8
+ end
9
+ end
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, in_threads: 4) do |step|
45
- step.execute_pre_conditions
46
- step.it_up unless step.failed?
47
- step.execute_post_conditions
48
- step.finish! unless step.failed?
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
@@ -1,3 +1,3 @@
1
1
  module Rockflow
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
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.1.2
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-05 00:00:00.000000000 Z
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: