pipeable 1.0.0 → 1.1.0
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 +4 -4
 - checksums.yaml.gz.sig +0 -0
 - data/README.adoc +21 -12
 - data/lib/pipeable/steps/insert.rb +4 -5
 - data/pipeable.gemspec +2 -2
 - data.tar.gz.sig +0 -0
 - metadata +4 -4
 - metadata.gz.sig +0 -0
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a09d8c73240d45d6a6a4219a6871a69ceb9ee77aa9387ac90b394571e2bfd24e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 3f0453d8efc7751c29c1f9ddd4f6aa7f5803478efa855d00ce913a434f2c4480
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bb6a5ff6689c93114eec07926f389d643ea26dcde8f157dda4a444a9236c25b959d2e52ae7d6479c0f3fd1911b208bbdaf148317d2915d68a99497b80b22329c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 610564b7b2de774b517996d524d189cf4ce9439a25df29a24c48ab0adf7fdd3da8acbb9bee573ba4a13fd12713124e6f6a4525627127876a8886607271c623c5
         
     | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/README.adoc
    CHANGED
    
    | 
         @@ -171,20 +171,20 @@ The following are the basic (default) steps for building custom pipes for which 
     | 
|
| 
       171 
171 
     | 
    
         | 
| 
       172 
172 
     | 
    
         
             
            ===== alt
         
     | 
| 
       173 
173 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
      
 174 
     | 
    
         
            +
            Short for _alternate_ which is the `or` branch of conditional logic. This allows you to operate on a failure and produce either a success or another failure. This is a convenience wrapper to native {dry_monads_link} `#or` functionality.
         
     | 
| 
       175 
175 
     | 
    
         | 
| 
       176 
176 
     | 
    
         
             
            Accepts a failure while answering either a success or failure. Example:
         
     | 
| 
       177 
177 
     | 
    
         | 
| 
       178 
178 
     | 
    
         
             
            [source,ruby]
         
     | 
| 
       179 
179 
     | 
    
         
             
            ----
         
     | 
| 
       180 
     | 
    
         
            -
            pipe %i[a b c], alt { |object| Success  
     | 
| 
      
 180 
     | 
    
         
            +
            pipe %i[a b c], alt { |object| Success "Pass!" }                   # Success [:a, :b, :c]
         
     | 
| 
       181 
181 
     | 
    
         
             
            pipe Failure("Danger!"), alt { Success "Resolved" }                # Success "Resolved"
         
     | 
| 
       182 
182 
     | 
    
         
             
            pipe Failure("Danger!"), alt { |object| Failure "Big #{object}" }  # Failure "Big Danger!"
         
     | 
| 
       183 
183 
     | 
    
         
             
            ----
         
     | 
| 
       184 
184 
     | 
    
         | 
| 
       185 
185 
     | 
    
         
             
            ===== amap
         
     | 
| 
       186 
186 
     | 
    
         | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
      
 187 
     | 
    
         
            +
            Short for _alternate map_ which allows you to unwrap a failure, make a modification, and wrap the modification as a new failure. This is a convenience wrapper to native {dry_monads_link} `#alt_map` functionality.
         
     | 
| 
       188 
188 
     | 
    
         | 
| 
       189 
189 
     | 
    
         
             
            Accepts and answers a failure. Example:
         
     | 
| 
       190 
190 
     | 
    
         | 
| 
         @@ -196,7 +196,7 @@ pipe Success("Pass"), amap { |object| "#{object}!" }    # Success "Pass" 
     | 
|
| 
       196 
196 
     | 
    
         | 
| 
       197 
197 
     | 
    
         
             
            ===== as
         
     | 
| 
       198 
198 
     | 
    
         | 
| 
       199 
     | 
    
         
            -
            Allows you to message an object  
     | 
| 
      
 199 
     | 
    
         
            +
            Allows you to message an object _as_ a different result. The first argument is always the method to message but additional positional and/or keyword arguments can be passed along if the method accepts them.
         
     | 
| 
       200 
200 
     | 
    
         | 
| 
       201 
201 
     | 
    
         
             
            Accepts and answers a success. Example:
         
     | 
| 
       202 
202 
     | 
    
         | 
| 
         @@ -209,7 +209,7 @@ pipe Failure("Danger!"), as(:inspect)  # Failure "Danger!" 
     | 
|
| 
       209 
209 
     | 
    
         | 
| 
       210 
210 
     | 
    
         
             
            ===== bind
         
     | 
| 
       211 
211 
     | 
    
         | 
| 
       212 
     | 
    
         
            -
            Allows you to perform operations upon success only. You are  
     | 
| 
      
 212 
     | 
    
         
            +
            Allows you to perform operations upon success only. You are responsible for answering a success or failure accordingly. This is a convenience wrapper to native {dry_monads_link} `#bind` functionality.
         
     | 
| 
       213 
213 
     | 
    
         | 
| 
       214 
214 
     | 
    
         
             
            Accepts a success while answering either a success or failure. Example:
         
     | 
| 
       215 
215 
     | 
    
         | 
| 
         @@ -235,7 +235,7 @@ pipe Failure("Danger!"), check(%i[a b], :include?)  # Failure "Danger!" 
     | 
|
| 
       235 
235 
     | 
    
         | 
| 
       236 
236 
     | 
    
         
             
            ===== fmap
         
     | 
| 
       237 
237 
     | 
    
         | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
      
 238 
     | 
    
         
            +
            Short for _function map_ which allows you to unwrap a success, make a modification, and wrap the modification as a new success. This is a convenience wrapper to native {dry_monads_link} `#fmap` functionality.
         
     | 
| 
       239 
239 
     | 
    
         | 
| 
       240 
240 
     | 
    
         
             
            Accepts and answers a success. Example:
         
     | 
| 
       241 
241 
     | 
    
         | 
| 
         @@ -247,7 +247,9 @@ pipe Failure("Danger!"), fmap { |object| object.join "-" }  # Failure "Danger!" 
     | 
|
| 
       247 
247 
     | 
    
         | 
| 
       248 
248 
     | 
    
         
             
            ===== insert
         
     | 
| 
       249 
249 
     | 
    
         | 
| 
       250 
     | 
    
         
            -
            Allows you to insert  
     | 
| 
      
 250 
     | 
    
         
            +
            Allows you to insert one or more elements after an object (default behavior) as a single array. This step wraps native link:https://rubyapi.org/o/array#method-i-insert[Array#insert] functionality. If the object is not an array, it will be cast as one. You can use the `:at` key to specify where you want insertion to happen. This step is most useful when needing to assemble _positional_ arguments for passing to a subsequent step.
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
            ⚠️ If given an array from the previous step, this step will mutate it.
         
     | 
| 
       251 
253 
     | 
    
         | 
| 
       252 
254 
     | 
    
         
             
            Accepts and answers a success. Example:
         
     | 
| 
       253 
255 
     | 
    
         | 
| 
         @@ -256,6 +258,9 @@ Accepts and answers a success. Example: 
     | 
|
| 
       256 
258 
     | 
    
         
             
            pipe :a, insert(:b)                  # Success [:a, :b]
         
     | 
| 
       257 
259 
     | 
    
         
             
            pipe :a, insert(:b, at: 0)           # Success [:b, :a]
         
     | 
| 
       258 
260 
     | 
    
         
             
            pipe %i[a c], insert(:b, at: 1)      # Success [:a, :b, :c]
         
     | 
| 
      
 261 
     | 
    
         
            +
            pipe :a, insert(:b, :c)              # Success [:a, :b, :c]
         
     | 
| 
      
 262 
     | 
    
         
            +
            pipe :a, insert([:b])                # Success [:a, [:b]]
         
     | 
| 
      
 263 
     | 
    
         
            +
            pipe :a, insert({b: 2})              # Success [:a, {b: 2}]
         
     | 
| 
       259 
264 
     | 
    
         
             
            pipe Failure("Danger!"), insert(:b)  # Failure "Danger!"
         
     | 
| 
       260 
265 
     | 
    
         
             
            ----
         
     | 
| 
       261 
266 
     | 
    
         | 
| 
         @@ -268,6 +273,7 @@ Accepts and answers a success. Example: 
     | 
|
| 
       268 
273 
     | 
    
         
             
            [source,ruby]
         
     | 
| 
       269 
274 
     | 
    
         
             
            ----
         
     | 
| 
       270 
275 
     | 
    
         
             
            pipe %i[a b c], map(&:inspect)           # Success [":a", ":b", ":c"]
         
     | 
| 
      
 276 
     | 
    
         
            +
            pipe %i[a b c], map { "#{it}1" }         # Success ["a1", "b1", "c1"]
         
     | 
| 
       271 
277 
     | 
    
         
             
            pipe Failure("Danger!"), map(&:inspect)  # Failure "Danger!"
         
     | 
| 
       272 
278 
     | 
    
         
             
            ----
         
     | 
| 
       273 
279 
     | 
    
         | 
| 
         @@ -275,19 +281,22 @@ pipe Failure("Danger!"), map(&:inspect)  # Failure "Danger!" 
     | 
|
| 
       275 
281 
     | 
    
         | 
| 
       276 
282 
     | 
    
         
             
            Allows you to merge an object with additional attributes as a single hash. This step wraps native link:https://rubyapi.org/o/hash#method-i-merge[Hash#merge] functionality. If the input is not a hash, then the object will be merged with `step` as the key. The default `step` key can be renamed to a different key by using the `:as` key. Like the _insert_ step, this step is most useful when assembling _keyword_ arguments and/or a hash for a subsequent steps.
         
     | 
| 
       277 
283 
     | 
    
         | 
| 
      
 284 
     | 
    
         
            +
            ⚠️ If given a hash from the previous step, this step will mutate it.
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
       278 
286 
     | 
    
         
             
            Accepts and answers a success. Example:
         
     | 
| 
       279 
287 
     | 
    
         | 
| 
       280 
288 
     | 
    
         
             
            [source,ruby]
         
     | 
| 
       281 
289 
     | 
    
         
             
            ----
         
     | 
| 
       282 
290 
     | 
    
         
             
            pipe({a: 1}, merge(b: 2))             # Success {a: 1, b: 2}
         
     | 
| 
       283 
     | 
    
         
            -
            pipe  
     | 
| 
       284 
     | 
    
         
            -
            pipe " 
     | 
| 
      
 291 
     | 
    
         
            +
            pipe({a: 1}, merge(b: 2, c: 3))       # Success {a: 1, b: 2, c: 3}
         
     | 
| 
      
 292 
     | 
    
         
            +
            pipe "demo", merge(b: 2)              # Success {step: "demo", b: 2}
         
     | 
| 
      
 293 
     | 
    
         
            +
            pipe "demo", merge(as: :a, b: 2)      # Success {a: "demo", b: 2}
         
     | 
| 
       285 
294 
     | 
    
         
             
            pipe Failure("Danger!"), merge(b: 2)  # Failure "Danger!"
         
     | 
| 
       286 
295 
     | 
    
         
             
            ----
         
     | 
| 
       287 
296 
     | 
    
         | 
| 
       288 
297 
     | 
    
         
             
            ===== tee
         
     | 
| 
       289 
298 
     | 
    
         | 
| 
       290 
     | 
    
         
            -
            Allows you to run an operation and ignore the response while input is passed through as output. This behavior is similar in nature to the link:https://www.gnu.org/savannah-checkouts/gnu/gawk/manual/html_node/Tee-Program.html[tee] program 
     | 
| 
      
 299 
     | 
    
         
            +
            Allows you to run an operation and ignore the response while input is passed through as output. This behavior is similar in nature to the link:https://www.gnu.org/savannah-checkouts/gnu/gawk/manual/html_node/Tee-Program.html[tee] Bash program.
         
     | 
| 
       291 
300 
     | 
    
         | 
| 
       292 
301 
     | 
    
         
             
            Accepts either a success or failure and passes the result through while allowing you to execute arbitrary behavior. Example:
         
     | 
| 
       293 
302 
     | 
    
         | 
| 
         @@ -361,7 +370,7 @@ pipe Failure("Danger!"), use(function)  # Failure "Danger!" 
     | 
|
| 
       361 
370 
     | 
    
         | 
| 
       362 
371 
     | 
    
         
             
            Allows you to use an contract for validating an object. This is especially useful when using {dry_schema_link}, {dry_validation_link}, or any contract that responds to `#call` and answers a `Result`.
         
     | 
| 
       363 
372 
     | 
    
         | 
| 
       364 
     | 
    
         
            -
            By default, the `:as` key's value is `nil`. Use `:to_h`, for example, as the value for automatic casting to a `Hash`. You can also pass  
     | 
| 
      
 373 
     | 
    
         
            +
            By default, the `:as` key's value is `nil`. Use `:to_h`, for example, as the value for automatic casting to a `Hash`. You can also pass any value to the `:as` key which is a valid method that the contract's result will respond to.
         
     | 
| 
       365 
374 
     | 
    
         | 
| 
       366 
375 
     | 
    
         
             
            Accepts a success and rewraps as a success if the `:as` keyword is supplied. Otherwise, any failure is immediately passed through. Example:
         
     | 
| 
       367 
376 
     | 
    
         | 
| 
         @@ -637,7 +646,7 @@ The following might be of aid to as you implement your own pipes. 
     | 
|
| 
       637 
646 
     | 
    
         
             
            If you get a `TypeError: Step must be functionally composable and answer a monad`, it means:
         
     | 
| 
       638 
647 
     | 
    
         | 
| 
       639 
648 
     | 
    
         
             
            . The step must be a `Proc`, `Method`, or any object which responds to `\#>>`, `#<<`, and `#call`.
         
     | 
| 
       640 
     | 
    
         
            -
            . The step doesn't answer a result monad (i.e. `Success 
     | 
| 
      
 649 
     | 
    
         
            +
            . The step doesn't answer a result monad (i.e. `Success` or `Failure`).
         
     | 
| 
       641 
650 
     | 
    
         | 
| 
       642 
651 
     | 
    
         
             
            ==== No Method Errors
         
     | 
| 
       643 
652 
     | 
    
         | 
| 
         @@ -6,22 +6,21 @@ module Pipeable 
     | 
|
| 
       6 
6 
     | 
    
         
             
                class Insert < Abstract
         
     | 
| 
       7 
7 
     | 
    
         
             
                  LAST = -1
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                  def initialize( 
     | 
| 
       10 
     | 
    
         
            -
                    super(* 
     | 
| 
       11 
     | 
    
         
            -
                    @value = positionals.empty? ? base_keywords : positionals.flatten
         
     | 
| 
      
 9 
     | 
    
         
            +
                  def initialize(*, at: LAST)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super(*)
         
     | 
| 
       12 
11 
     | 
    
         
             
                    @at = at
         
     | 
| 
       13 
12 
     | 
    
         
             
                  end
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
14 
     | 
    
         
             
                  def call result
         
     | 
| 
       16 
15 
     | 
    
         
             
                    result.fmap do |object|
         
     | 
| 
       17 
16 
     | 
    
         
             
                      cast = object.is_a?(Array) ? object : [object]
         
     | 
| 
       18 
     | 
    
         
            -
                       
     | 
| 
      
 17 
     | 
    
         
            +
                      cast.insert(at, *base_positionals)
         
     | 
| 
       19 
18 
     | 
    
         
             
                    end
         
     | 
| 
       20 
19 
     | 
    
         
             
                  end
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
       22 
21 
     | 
    
         
             
                  private
         
     | 
| 
       23 
22 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 23 
     | 
    
         
            +
                  attr_reader :at
         
     | 
| 
       25 
24 
     | 
    
         
             
                end
         
     | 
| 
       26 
25 
     | 
    
         
             
              end
         
     | 
| 
       27 
26 
     | 
    
         
             
            end
         
     | 
    
        data/pipeable.gemspec
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       4 
4 
     | 
    
         
             
              spec.name = "pipeable"
         
     | 
| 
       5 
     | 
    
         
            -
              spec.version = "1. 
     | 
| 
      
 5 
     | 
    
         
            +
              spec.version = "1.1.0"
         
     | 
| 
       6 
6 
     | 
    
         
             
              spec.authors = ["Brooke Kuhlmann"]
         
     | 
| 
       7 
7 
     | 
    
         
             
              spec.email = ["brooke@alchemists.io"]
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.homepage = "https://alchemists.io/projects/pipeable"
         
     | 
| 
         @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       25 
25 
     | 
    
         
             
              spec.required_ruby_version = "~> 3.4"
         
     | 
| 
       26 
26 
     | 
    
         
             
              spec.add_dependency "containable", "~> 1.0"
         
     | 
| 
       27 
27 
     | 
    
         
             
              spec.add_dependency "dry-monads", "~> 1.6"
         
     | 
| 
       28 
     | 
    
         
            -
              spec.add_dependency "marameters", "~> 4. 
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_dependency "marameters", "~> 4.1"
         
     | 
| 
       29 
29 
     | 
    
         
             
              spec.add_dependency "refinements", "~> 13.0"
         
     | 
| 
       30 
30 
     | 
    
         
             
              spec.add_dependency "zeitwerk", "~> 2.7"
         
     | 
| 
       31 
31 
     | 
    
         | 
    
        data.tar.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pipeable
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Brooke Kuhlmann
         
     | 
| 
         @@ -34,7 +34,7 @@ cert_chain: 
     | 
|
| 
       34 
34 
     | 
    
         
             
              3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
         
     | 
| 
       35 
35 
     | 
    
         
             
              gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
         
     | 
| 
       36 
36 
     | 
    
         
             
              -----END CERTIFICATE-----
         
     | 
| 
       37 
     | 
    
         
            -
            date:  
     | 
| 
      
 37 
     | 
    
         
            +
            date: 2025-01-10 00:00:00.000000000 Z
         
     | 
| 
       38 
38 
     | 
    
         
             
            dependencies:
         
     | 
| 
       39 
39 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       40 
40 
     | 
    
         
             
              name: containable
         
     | 
| 
         @@ -70,14 +70,14 @@ dependencies: 
     | 
|
| 
       70 
70 
     | 
    
         
             
                requirements:
         
     | 
| 
       71 
71 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       72 
72 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       73 
     | 
    
         
            -
                    version: '4. 
     | 
| 
      
 73 
     | 
    
         
            +
                    version: '4.1'
         
     | 
| 
       74 
74 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       75 
75 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       76 
76 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       77 
77 
     | 
    
         
             
                requirements:
         
     | 
| 
       78 
78 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       79 
79 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       80 
     | 
    
         
            -
                    version: '4. 
     | 
| 
      
 80 
     | 
    
         
            +
                    version: '4.1'
         
     | 
| 
       81 
81 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       82 
82 
     | 
    
         
             
              name: refinements
         
     | 
| 
       83 
83 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
    
        metadata.gz.sig
    CHANGED
    
    | 
         Binary file 
     |