pipeable 0.14.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +5 -5
- data.tar.gz.sig +0 -0
- metadata +10 -17
- 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 = "
|
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"
|
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.signing_key = Gem.default_key_path
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
24
24
|
|
25
|
-
spec.required_ruby_version = "
|
26
|
-
spec.add_dependency "containable", "~> 0
|
25
|
+
spec.required_ruby_version = "~> 3.4"
|
26
|
+
spec.add_dependency "containable", "~> 1.0"
|
27
27
|
spec.add_dependency "dry-monads", "~> 1.6"
|
28
|
-
spec.add_dependency "marameters", "~>
|
29
|
-
spec.add_dependency "refinements", "~>
|
28
|
+
spec.add_dependency "marameters", "~> 4.1"
|
29
|
+
spec.add_dependency "refinements", "~> 13.0"
|
30
30
|
spec.add_dependency "zeitwerk", "~> 2.7"
|
31
31
|
|
32
32
|
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipeable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
@@ -35,7 +34,7 @@ cert_chain:
|
|
35
34
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
35
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
36
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
37
|
+
date: 2025-01-10 00:00:00.000000000 Z
|
39
38
|
dependencies:
|
40
39
|
- !ruby/object:Gem::Dependency
|
41
40
|
name: containable
|
@@ -43,14 +42,14 @@ dependencies:
|
|
43
42
|
requirements:
|
44
43
|
- - "~>"
|
45
44
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0
|
45
|
+
version: '1.0'
|
47
46
|
type: :runtime
|
48
47
|
prerelease: false
|
49
48
|
version_requirements: !ruby/object:Gem::Requirement
|
50
49
|
requirements:
|
51
50
|
- - "~>"
|
52
51
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0
|
52
|
+
version: '1.0'
|
54
53
|
- !ruby/object:Gem::Dependency
|
55
54
|
name: dry-monads
|
56
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,28 +70,28 @@ dependencies:
|
|
71
70
|
requirements:
|
72
71
|
- - "~>"
|
73
72
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
73
|
+
version: '4.1'
|
75
74
|
type: :runtime
|
76
75
|
prerelease: false
|
77
76
|
version_requirements: !ruby/object:Gem::Requirement
|
78
77
|
requirements:
|
79
78
|
- - "~>"
|
80
79
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
80
|
+
version: '4.1'
|
82
81
|
- !ruby/object:Gem::Dependency
|
83
82
|
name: refinements
|
84
83
|
requirement: !ruby/object:Gem::Requirement
|
85
84
|
requirements:
|
86
85
|
- - "~>"
|
87
86
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
87
|
+
version: '13.0'
|
89
88
|
type: :runtime
|
90
89
|
prerelease: false
|
91
90
|
version_requirements: !ruby/object:Gem::Requirement
|
92
91
|
requirements:
|
93
92
|
- - "~>"
|
94
93
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
94
|
+
version: '13.0'
|
96
95
|
- !ruby/object:Gem::Dependency
|
97
96
|
name: zeitwerk
|
98
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +106,6 @@ dependencies:
|
|
107
106
|
- - "~>"
|
108
107
|
- !ruby/object:Gem::Version
|
109
108
|
version: '2.7'
|
110
|
-
description:
|
111
109
|
email:
|
112
110
|
- brooke@alchemists.io
|
113
111
|
executables: []
|
@@ -150,16 +148,12 @@ metadata:
|
|
150
148
|
label: Pipeable
|
151
149
|
rubygems_mfa_required: 'true'
|
152
150
|
source_code_uri: https://github.com/bkuhlmann/pipeable
|
153
|
-
post_install_message:
|
154
151
|
rdoc_options: []
|
155
152
|
require_paths:
|
156
153
|
- lib
|
157
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
158
155
|
requirements:
|
159
|
-
- - "
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: '3.3'
|
162
|
-
- - "<="
|
156
|
+
- - "~>"
|
163
157
|
- !ruby/object:Gem::Version
|
164
158
|
version: '3.4'
|
165
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -168,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
162
|
- !ruby/object:Gem::Version
|
169
163
|
version: '0'
|
170
164
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
172
|
-
signing_key:
|
165
|
+
rubygems_version: 3.6.2
|
173
166
|
specification_version: 4
|
174
167
|
summary: A domain specific language for building functionally composable steps.
|
175
168
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|