nxt_pipeline 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: 1da9d5e3b469a3d6efc43d65f317543bfad3e40db75b04ca14412dbec9b88a0d
4
- data.tar.gz: 02ae090bc54b42cdac7e24be6791262798d108edc8a623c193c1315ff14db0b3
3
+ metadata.gz: 4103a1a9d5d3220e1b2f6df7776878cc478d7ceec612e0f743fa24f3405b942a
4
+ data.tar.gz: 84c9da4b2f27e5814220f14007f7de259267a9dfca168ecfa4a69a97065abbbd
5
5
  SHA512:
6
- metadata.gz: 4f92784765feabb90d49e2fd73716447f6828a61041961543f147db5def7f734e2cda011ee6369e339dcddc574c7b3b4ef6fc7f0d1fccd6ca3a9ef57fa8fc6f8
7
- data.tar.gz: ca7a445f29c736c82963aac18251c28418a084645e8b7dab009abacd57b068bc656d0e8cd39c98f6a6b8e017c1fd1450dc227da37fb00915a2d8fd57c90b2bee
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.1)
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.2.1)
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
- return result
85
+ result
78
86
  else # step was not successful if nil or false
79
87
  log[current_step] = { status: :skipped }
80
- return arg
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
@@ -1,3 +1,3 @@
1
1
  module NxtPipeline
2
- VERSION = "0.2.2".freeze
2
+ VERSION = "0.2.3".freeze
3
3
  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.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nils Sommer