standard-procedure-plumbing 0.5.0 → 0.5.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: 90c456ba1b4ae2cebb75d1fe5ac49f806c6156387a5907980255e2f224b11f54
4
- data.tar.gz: b40ea0aa31ce5608d94721c90d56a351cdf834660fe32398d4c2e6e5c0dd4827
3
+ metadata.gz: 8071e0d012d60099bd30afaaabe7274fe4572a88686115e9b8db86fe880a0734
4
+ data.tar.gz: 212b5f27a5309d3cd638e354d8a41cbd77dcf0a5b9f22d5976e04403cea200a4
5
5
  SHA512:
6
- metadata.gz: b2a394f3a3924edc4963252e59170fec110c7190d2305e90e5ecb483e84cfff818c75074abeb975f4561ca01086cad1c7971d26b91eec3be0da8c6a46c0fa869
7
- data.tar.gz: b3b790c91098bea951a175ec9d2b8676e2e630fb4c4eef6e225855b5b7a472782bc6eb6f98f1c5c3f339878560fbad5c060a75cecec15748105735320ab09379
6
+ metadata.gz: 82e7bf5617439df2e00886e7d95e9c4215e5f2e7dcf91a6a5de3673cd132bbc069c301fd0cdeb4cd315faff76981a4282898da66771be57ce19c7d9589fa7a30
7
+ data.tar.gz: c64ee286c7fec70b9025bd32ceaa39379751d26f7e7947934f07c5651f62f564407a87a4227fd2e4202c042b2d9db7df48008e67ba06aea9f15b269b7606cd15
data/README.md CHANGED
@@ -41,9 +41,14 @@ require 'plumbing'
41
41
  Plumbing.config mode: :async
42
42
  ```
43
43
 
44
+ ## Development
44
45
 
46
+ ### To Do
45
47
 
46
- ## Development
48
+ - [ ] Add a debouncing filter for pipes
49
+ - [ ] Pass the mode as a block parameter in `Plumbing::Spec.modes`
50
+ - [ ] Move Plumbing::Actor::Transporter to Plumbing::Transporter ?? (planning to use it outside of Plumbing so would make sense not to imply it is tied to Actors)
51
+ - [X] Ensure transporters deal with GlobalID models not being found / errors when unpacking
47
52
 
48
53
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
54
 
@@ -51,7 +56,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
51
56
 
52
57
  ## Contributing
53
58
 
54
- Bug reports and pull requests are welcome on GitHub at https://github.com/standard_procedure/plumbing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/standard_procedure/plumbing/blob/main/CODE_OF_CONDUCT.md).
59
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/standard_procedure/plumbing>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/standard_procedure/plumbing/blob/main/CODE_OF_CONDUCT.md).
55
60
 
56
61
  ## Code of Conduct
57
62
 
@@ -55,6 +55,9 @@ module Plumbing
55
55
 
56
56
  def unpack_string argument
57
57
  argument.start_with?("gid://") ? GlobalID::Locator.locate(argument) : argument
58
+ rescue => ex
59
+ Plumbing.config.logger.error "!!!! #{self.class}##{__callee__} - #{argument} => #{ex}"
60
+ argument
58
61
  end
59
62
  end
60
63
  end
@@ -86,7 +86,7 @@ module Plumbing
86
86
  instance_eval(&)
87
87
  nil
88
88
  rescue => ex
89
- Plumbing.config.logger.error { "!!!! #{self.class}#perform_safely => #{ex}" }
89
+ Plumbing.config.logger.error { "!!!! #{self.class}##{__callee__} => #{ex}" }
90
90
  nil
91
91
  end
92
92
  end
data/lib/plumbing/pipe.rb CHANGED
@@ -9,12 +9,12 @@ module Plumbing
9
9
  # @param event_name [String] representing the type of event this is
10
10
  # @param data [Hash] representing the event-specific data to be passed to the observers
11
11
  def notify event_name, **data
12
- Plumbing.config.logger.debug { "-> #{self.class}#notify #{event_name}" }
12
+ Plumbing.config.logger.debug { "-> #{self.class}##{__callee__} #{event_name}" }
13
13
  observers.each do |observer|
14
- Plumbing.config.logger.debug { "===> #{self.class}#dispatch #{event_name}(#{data}) to #{observer}" }
14
+ Plumbing.config.logger.debug { "===> #{self.class}#call #{event_name}(#{data}) to #{observer}" }
15
15
  observer.call event_name, data
16
16
  rescue => ex
17
- Plumbing.config.logger.error { "!!!! #{self.class}#dispatch #{event_name} => #{ex}" }
17
+ Plumbing.config.logger.error { "!!!! #{self.class}##{__callee__} #{event_name} => #{ex}" }
18
18
  ex
19
19
  end
20
20
  end
@@ -58,6 +58,5 @@ module Plumbing
58
58
 
59
59
  require_relative "pipe/filter"
60
60
  require_relative "pipe/junction"
61
-
62
61
  end
63
62
  end
@@ -7,7 +7,7 @@ module Plumbing
7
7
  # @yield [Object] input the input data to be validated
8
8
  # @yieldreturn [Boolean] true to accept the input, false to reject it
9
9
  def pre_condition name, &validator
10
- pre_conditions[name.to_sym] = validator
10
+ pre_conditions << ConditionValidator.new(name.to_s, validator)
11
11
  end
12
12
 
13
13
  # @param [String] contract_class the class name of the [Dry::Validation::Contract] that will be used to validate the input data
@@ -20,17 +20,21 @@ module Plumbing
20
20
  # @yield [Object] output the output data to be validated
21
21
  # @yieldreturn [Boolean] true to accept the output, false to reject it
22
22
  def post_condition name, &validator
23
- post_conditions[name.to_sym] = validator
23
+ post_conditions << ConditionValidator.new(name.to_s, validator)
24
24
  end
25
25
 
26
26
  private
27
27
 
28
+ class ConditionValidator < Struct.new(:name, :validator)
29
+ def call(input) = validator.call input
30
+ end
31
+
28
32
  def pre_conditions
29
- @pre_conditions ||= {}
33
+ @pre_conditions ||= []
30
34
  end
31
35
 
32
36
  def post_conditions
33
- @post_conditions ||= {}
37
+ @post_conditions ||= []
34
38
  end
35
39
 
36
40
  def validate_contract_for input
@@ -41,14 +45,22 @@ module Plumbing
41
45
  end
42
46
 
43
47
  def validate_preconditions_for input
44
- failed_preconditions = pre_conditions.select { |name, validator| !validator.as(Callable).call(input) }
45
- raise PreConditionError, failed_preconditions.keys.join(", ") if failed_preconditions.any?
48
+ failed_preconditions = pre_conditions.select do |validator|
49
+ !validator.call(input)
50
+ rescue
51
+ true
52
+ end
53
+ raise PreConditionError, failed_preconditions.map(&:name).join(", ") if failed_preconditions.any?
46
54
  input
47
55
  end
48
56
 
49
57
  def validate_postconditions_for output
50
- failed_postconditions = post_conditions.select { |name, validator| !validator.as(Callable).call(output) }
51
- raise PostConditionError, failed_postconditions.keys.join(", ") if failed_postconditions.any?
58
+ failed_postconditions = post_conditions.select do |validator|
59
+ !validator.call(output)
60
+ rescue
61
+ true
62
+ end
63
+ raise PostConditionError, failed_postconditions.map(&:name).join(", ") if failed_postconditions.any?
52
64
  output
53
65
  end
54
66
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plumbing
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard-procedure-plumbing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-20 00:00:00.000000000 Z
11
+ date: 2024-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: globalid
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.5.12
84
+ rubygems_version: 3.5.20
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Plumbing - various pipelines for your ruby application