nxt_pipeline 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/nxt_pipeline/pipeline.rb +12 -9
- data/lib/nxt_pipeline/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4103a1a9d5d3220e1b2f6df7776878cc478d7ceec612e0f743fa24f3405b942a
|
4
|
+
data.tar.gz: 84c9da4b2f27e5814220f14007f7de259267a9dfca168ecfa4a69a97065abbbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5f3d8efeb773ed700bbcd30aba75415554ab6221e4a95d518d38d9cf32d00c8982eca0e8ad0d46f280b25c845d3a306eda59e6797a8d94d2551740761a8d68
|
7
|
+
data.tar.gz: 7201abcca537229b6bc27d458a428f84f510c14a0a2c926af8387b2025f719e4336b22c062ba3b591c17adfb73f9c91039b99d2d731897b7d1d51e47ab8ca838
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nxt_pipeline (0.2.
|
4
|
+
nxt_pipeline (0.2.2)
|
5
5
|
activesupport
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (5.2.
|
10
|
+
activesupport (5.2.3)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
12
|
i18n (>= 0.7, < 2)
|
13
13
|
minitest (~> 5.1)
|
@@ -9,6 +9,7 @@ module NxtPipeline
|
|
9
9
|
@error_callbacks = []
|
10
10
|
@log = {}
|
11
11
|
@current_step = nil
|
12
|
+
@current_arg = nil
|
12
13
|
@default_constructor = nil
|
13
14
|
@registry = {}
|
14
15
|
configure(&block) if block_given?
|
@@ -49,6 +50,12 @@ module NxtPipeline
|
|
49
50
|
steps.inject(arg) do |argument, step|
|
50
51
|
execute_step(step, argument)
|
51
52
|
end
|
53
|
+
rescue StandardError => error
|
54
|
+
log[current_step] = { status: :failed, reason: "#{error.class}: #{error.message}" }
|
55
|
+
callback = find_error_callback(error)
|
56
|
+
|
57
|
+
raise unless callback
|
58
|
+
callback.call(current_step, current_arg, error)
|
52
59
|
end
|
53
60
|
|
54
61
|
def on_errors(*errors, &callback)
|
@@ -65,26 +72,21 @@ module NxtPipeline
|
|
65
72
|
private
|
66
73
|
|
67
74
|
attr_reader :error_callbacks, :registry
|
68
|
-
attr_accessor :steps, :current_step, :default_constructor
|
75
|
+
attr_accessor :steps, :current_step, :current_arg, :default_constructor
|
69
76
|
attr_writer :log
|
70
77
|
|
71
78
|
def execute_step(step, arg)
|
72
79
|
self.current_step = step.to_s
|
80
|
+
self.current_arg = arg
|
73
81
|
result = step.execute(arg)
|
74
82
|
|
75
83
|
if result # step was successful
|
76
84
|
log[current_step] = { status: :success }
|
77
|
-
|
85
|
+
result
|
78
86
|
else # step was not successful if nil or false
|
79
87
|
log[current_step] = { status: :skipped }
|
80
|
-
|
88
|
+
arg
|
81
89
|
end
|
82
|
-
rescue StandardError => error
|
83
|
-
log[current_step] = { status: :failed, reason: "#{error.class}: #{error.message}" }
|
84
|
-
callback = find_error_callback(error)
|
85
|
-
|
86
|
-
raise unless callback
|
87
|
-
callback.call(step, arg, error)
|
88
90
|
end
|
89
91
|
|
90
92
|
def find_error_callback(error)
|
@@ -93,6 +95,7 @@ module NxtPipeline
|
|
93
95
|
|
94
96
|
def reset_log
|
95
97
|
self.log = {}
|
98
|
+
self.current_arg = nil
|
96
99
|
end
|
97
100
|
end
|
98
101
|
end
|
data/lib/nxt_pipeline/version.rb
CHANGED