nxt_pipeline 0.2.5 → 0.2.6

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: 7aa1fdbbfb4c1d0eb99c72270cf13893f34fda78162abb749091600b1857f8bb
4
- data.tar.gz: adce759515d5d7ee687eaf96221083127e089946945095d8ddf931348f4d4826
3
+ metadata.gz: e5b6a6aecafbd42348179870b4fb233198d36f57fcaf9bc15a73ec1cf94c7153
4
+ data.tar.gz: 550eb798e64c2cf093bb991589c5fc3b711e01da213d9079efa690ad5bfd7f07
5
5
  SHA512:
6
- metadata.gz: f3a040fe24d3e4329d7241eba0d21c49f0696027bf8e39550a7cf473c3a80e7b86f1313a00fe4c78feac2a6621f8a6b55d7f6e05eadd0a674b5782bb70e8d3f2
7
- data.tar.gz: a9e3ad99022ef92321e680e664207f296bd69f9ffe2f12edb8193f129e102fe4bc0b52363af769b4408ed36dcec8a29329bfedf0da06f28ae2c5929e54850a02
6
+ metadata.gz: 854f0e2cdfe534178509d440d5f997c37734a91389c1f994e64054f5a9ffcbe125f90b61eaf4721214ada62f34abed5378fb734538398a2a34d61eb3926aa55d
7
+ data.tar.gz: c5c1dc5effe486335cffe8fdb766bb756fdb0c55825d89169daea456694fea809ae0938d13500765a09ab364b5aad11c0ce4a6f1b20573db38361f1907a36061
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ vendor/cache/
9
10
  .idea/
10
11
 
11
12
  # rspec failure tracking
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.2
1
+ 2.6.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nxt_pipeline (0.2.4)
4
+ nxt_pipeline (0.2.6)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -15,7 +15,7 @@ GEM
15
15
  coderay (1.1.2)
16
16
  concurrent-ruby (1.1.5)
17
17
  diff-lcs (1.3)
18
- ffi (1.10.0)
18
+ ffi (1.11.1)
19
19
  formatador (0.2.5)
20
20
  guard (2.15.0)
21
21
  formatador (>= 0.2.4)
@@ -47,7 +47,7 @@ GEM
47
47
  pry (0.12.2)
48
48
  coderay (~> 1.1.0)
49
49
  method_source (~> 0.9.0)
50
- rake (10.5.0)
50
+ rake (12.3.3)
51
51
  rb-fsevent (0.10.3)
52
52
  rb-inotify (0.10.0)
53
53
  ffi (~> 1.0)
@@ -55,15 +55,15 @@ GEM
55
55
  rspec-core (~> 3.8.0)
56
56
  rspec-expectations (~> 3.8.0)
57
57
  rspec-mocks (~> 3.8.0)
58
- rspec-core (3.8.0)
58
+ rspec-core (3.8.1)
59
59
  rspec-support (~> 3.8.0)
60
- rspec-expectations (3.8.2)
60
+ rspec-expectations (3.8.4)
61
61
  diff-lcs (>= 1.2.0, < 2.0)
62
62
  rspec-support (~> 3.8.0)
63
- rspec-mocks (3.8.0)
63
+ rspec-mocks (3.8.1)
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
65
  rspec-support (~> 3.8.0)
66
- rspec-support (3.8.0)
66
+ rspec-support (3.8.2)
67
67
  rspec_junit_formatter (0.4.1)
68
68
  rspec-core (>= 2, < 4, != 2.12.0)
69
69
  ruby_dep (1.5.0)
@@ -81,7 +81,7 @@ DEPENDENCIES
81
81
  guard-rspec
82
82
  nxt_pipeline!
83
83
  pry
84
- rake (~> 10.0)
84
+ rake (~> 12.3)
85
85
  rspec (~> 3.0)
86
86
  rspec_junit_formatter
87
87
 
data/README.md CHANGED
@@ -109,10 +109,21 @@ end
109
109
  ```
110
110
 
111
111
  You can query the steps of your pipeline simply by calling `pipeline.steps`. A NxtPipeline::Step will provide you with
112
- an interface it's type, options, status (:success, :skipped, :failed), result, error and the index in the pipeline.
112
+ an interface to it's type, options, status (:success, :skipped, :failed), result, error and the index in the pipeline.
113
113
 
114
114
  ```
115
115
  pipeline.steps.first
116
+ # will give you something like this:
117
+
118
+ #<NxtPipeline::Step:0x00007f83eb399448
119
+ @constructor=
120
+ #<Proc:0x00007f83eb399498@/Users/andy/workspace/nxt_pipeline/spec/pipeline_spec.rb:467>,
121
+ @error=nil,
122
+ @index=0,
123
+ @opts={:to_s=>:transformer, :method=>:upcase},
124
+ @result=nil,
125
+ @status=nil,
126
+ @type=:transformer>
116
127
  ```
117
128
 
118
129
  ### Error callbacks
@@ -133,6 +144,11 @@ NxtPipeline::Pipeline.new do |p|
133
144
  # First matching error callback will be executed!
134
145
  end
135
146
 
147
+ p.on_errors YetAnotherError, halt_on_error: false do |step, arg, error|
148
+ # After executing the callback the pipeline will not halt but continue to
149
+ # execute the next steps.
150
+ end
151
+
136
152
  p.on_errors do |step, arg, error|
137
153
  # This will match all errors inheriting from StandardError
138
154
  end
@@ -147,6 +163,7 @@ You can also define callbacks that run before and after the `#execute` action. B
147
163
  NxtPipeline::Pipeline.new do |p|
148
164
  p.before_execute do |pipeline, arg|
149
165
  # Will be called from within #execute before entering the first step
166
+ # After any configure block though!
150
167
  end
151
168
 
152
169
  p.after_execute do |pipeline, arg|
@@ -1,12 +1,21 @@
1
1
  module NxtPipeline
2
2
  class ErrorCallback
3
- def initialize(errors, callback)
3
+ def initialize(errors, halt_on_error, callback)
4
4
  @errors = errors
5
+ @halt_on_error = halt_on_error
5
6
  @callback = callback
6
7
  end
7
8
 
8
9
  attr_accessor :errors, :callback
9
10
 
11
+ def halt_on_error?
12
+ @halt_on_error
13
+ end
14
+
15
+ def continue_after_error?
16
+ !halt_on_error?
17
+ end
18
+
10
19
  def applies_to_error?(error)
11
20
  (error.class.ancestors & errors).any?
12
21
  end
@@ -72,11 +72,21 @@ module NxtPipeline
72
72
 
73
73
  result = steps.inject(arg) do |argument, step|
74
74
  execute_step(step, argument)
75
+ rescue StandardError => error
76
+ puts step
77
+ callback = find_error_callback(error)
78
+ raise unless callback && callback.continue_after_error?
79
+ handle_step_error(error)
80
+ argument
75
81
  end
76
82
 
77
83
  after_execute_callback.call(self, result) if after_execute_callback.respond_to?(:call)
78
84
  result
79
85
  rescue StandardError => error
86
+ handle_step_error(error)
87
+ end
88
+
89
+ def handle_step_error(error)
80
90
  log_step(current_step)
81
91
  callback = find_error_callback(error)
82
92
 
@@ -85,8 +95,8 @@ module NxtPipeline
85
95
  callback.call(current_step, current_arg, error)
86
96
  end
87
97
 
88
- def on_errors(*errors, &callback)
89
- error_callbacks << ErrorCallback.new(errors, callback)
98
+ def on_errors(*errors, halt_on_error: true, &callback)
99
+ error_callbacks << ErrorCallback.new(errors, halt_on_error, callback)
90
100
  end
91
101
 
92
102
  alias :on_error :on_errors
@@ -1,3 +1,3 @@
1
1
  module NxtPipeline
2
- VERSION = "0.2.5".freeze
2
+ VERSION = "0.2.6".freeze
3
3
  end
data/nxt_pipeline.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "activesupport"
38
38
  spec.add_development_dependency "bundler", "~> 1.17"
39
39
  spec.add_development_dependency "guard-rspec"
40
- spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rake", "~> 12.3"
41
41
  spec.add_development_dependency "rspec", "~> 3.0"
42
42
  spec.add_development_dependency "pry"
43
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nxt_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nils Sommer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-06-16 00:00:00.000000000 Z
13
+ date: 2019-07-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '10.0'
63
+ version: '12.3'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '10.0'
70
+ version: '12.3'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rspec
73
73
  requirement: !ruby/object:Gem::Requirement