ruby_pipeline 1.0.1 → 1.0.2

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: f58ba14a41f2738f813dc20a2510cba4b2d285db8f0b1dc91ad5cbec2961b58a
4
- data.tar.gz: 96b44437c7e11c1c0675c584691148e948025473ede0cf37ec6e31325a691c38
3
+ metadata.gz: 7cc7cfeb3879fd62c07181a10e3baebd2afde5a8548980753280a204faad2df6
4
+ data.tar.gz: c33bc404cfdd411519b93c0974844ad36531f0a501291d8474408ebbd2f1bd1a
5
5
  SHA512:
6
- metadata.gz: e109b4ef939340aaab83c9977bfc3382668b6ba9a891b2c7b02ae8989bf62b561031db0d7cb424472417d87e4b5c93ddf891d2d28d2bb8e1decbb935ae1cde4c
7
- data.tar.gz: 8aaeb919db7af405b8be73ef8c50272018233aeee1bfa0e95aae7fed5fcef557c03dd1d717fb160979cc9cd431985d1f0858f1f4c4e55b028f6492b32980ff09
6
+ metadata.gz: aeb401777d2f58447d94e445930bae2902d6b4de5440608bdba59bdb1b1cba5535b96e1886230653dd5a01f5824edf015bfa19193bac693a5a64c3d328b30877
7
+ data.tar.gz: 60bc128f2c34d17cad5f1c44152540f8e795d27e239961eed29f8b8fd2ec3b4848ae1a1666f4ce963cda23068022b182731787a3521856321983a31170679b90
data/README.md CHANGED
@@ -67,6 +67,11 @@ You can configure a success callback to be called after each step is processed:
67
67
  RubyPipeline.configure do |config|
68
68
  config.success_callback = ->(step) { my_monitoring_service.notify(step) }
69
69
  config.failure_callback = ->(step) { puts "Failure in step #{step}" }
70
+ config.time_callback = lambda do |step, &block|
71
+ my_timing_service.time(step) do
72
+ block.call # Important to call the block, otherwise the pipeline will not continue
73
+ end
74
+ end
70
75
  end
71
76
  ```
72
77
 
@@ -8,7 +8,7 @@ module RubyPipeline
8
8
 
9
9
  def process(input = nil)
10
10
  steps.inject(input) do |memo, step|
11
- step_result = step.process(memo)
11
+ step_result = time(step) { step.process(memo) }
12
12
 
13
13
  break failure(step) if step_result.nil?
14
14
 
@@ -23,6 +23,7 @@ module RubyPipeline
23
23
 
24
24
  def default_steps = []
25
25
 
26
+ def time(step, &) = RubyPipeline.configuration.time_callback.call(step, &)
26
27
  def success(step) = RubyPipeline.configuration.success_callback.call(step)
27
28
 
28
29
  def failure(step)
@@ -2,11 +2,12 @@
2
2
 
3
3
  module RubyPipeline
4
4
  class Configuration
5
- attr_accessor :success_callback, :failure_callback
5
+ attr_accessor :success_callback, :failure_callback, :time_callback
6
6
 
7
7
  def initialize
8
8
  @success_callback = ->(step) {}
9
9
  @failure_callback = ->(step) {}
10
+ @time_callback = ->(_step, &block) { block.call }
10
11
  end
11
12
  end
12
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyPipeline
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Vaughan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-08-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: ian@out.fund