pipeable 0.1.0 → 0.2.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 +10 -12
- data/lib/pipeable/{stepable.rb → definer.rb} +10 -12
- data/lib/pipeable/steps/container.rb +15 -15
- data/lib/pipeable.rb +7 -2
- data/pipeable.gemspec +2 -2
- data.tar.gz.sig +0 -0
- metadata +7 -7
- 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: adfcbe3f56342f3a92393c79a301f95dfbc71cbf0c46a9be4fb4c2ca0279690a
|
4
|
+
data.tar.gz: c626ab5ea4431bf9c039ee0461a30255d57206a3153ef20017edaaf78ec233e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25c6943f6b37242819457db49debdc08c6e466464d4f79fa767c523710ab24a8095688edee622eb9a791d11a71d7384fdeeab97eed07d694badd7295a4186042
|
7
|
+
data.tar.gz: 4bdaf170441d0ef85ba66e00941bb15c88b3b3f638690601041f8351b4b0f40c088e9d2e1e872ec1afa4563321649d00ef06e6a4fc25d3547926e5e2093a089d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -3,9 +3,8 @@
|
|
3
3
|
:figure-caption!:
|
4
4
|
|
5
5
|
:command_pattern_link: link:https://alchemists.io/articles/command_pattern[Command Pattern]
|
6
|
+
:containable_link: link:https://alchemists.io/projects/containable[Containable]
|
6
7
|
:debug_link: link:https://github.com/ruby/debug[Debug]
|
7
|
-
:dry_container_link: link:https://dry-rb.org/gems/dry-container[Dry Container]
|
8
|
-
:dry_events_link: link:https://dry-rb.org/gems/dry-events[Dry Events]
|
9
8
|
:dry_monads_link: link:https://dry-rb.org/gems/dry-monads[Dry Monads]
|
10
9
|
:dry_schema_link: link:https://dry-rb.org/gems/dry-schema[Dry Schema]
|
11
10
|
:dry_validation_link: link:https://dry-rb.org/gems/dry-validation[Dry Validation]
|
@@ -25,8 +24,7 @@ toc::[]
|
|
25
24
|
* Adheres to the {railway_pattern_link}.
|
26
25
|
* Provides built-in and customizable domain-specific steps.
|
27
26
|
* Provides chainable _pipes_ which can be used to build more complex workflows.
|
28
|
-
* Compatible with {dry_monads_link}.
|
29
|
-
* Compatible with {infusible_link}.
|
27
|
+
* Compatible with the {containable_link}, {infusible_link}, and {dry_monads_link} gems.
|
30
28
|
|
31
29
|
== Requirements
|
32
30
|
|
@@ -415,7 +413,7 @@ module CustomSteps
|
|
415
413
|
end
|
416
414
|
end
|
417
415
|
|
418
|
-
Pipeable::Steps::Container.register
|
416
|
+
Pipeable::Steps::Container.register :join, CustomSteps::Join
|
419
417
|
|
420
418
|
include Pipeable
|
421
419
|
|
@@ -428,27 +426,27 @@ pipe :a, insert(:b), join(""), as(:to_sym)
|
|
428
426
|
|
429
427
|
=== Containers
|
430
428
|
|
431
|
-
Should you not want the basic steps, need custom steps, or a hybrid of default and custom steps, you can define your own container and provide it as an argument to `.
|
429
|
+
Should you not want the basic steps, need custom steps, or a hybrid of default and custom steps, you can define your own container and provide it as an argument to `.[]` when including pipeable behavior. Example:
|
432
430
|
|
433
431
|
[source,ruby]
|
434
432
|
----
|
435
|
-
require "
|
433
|
+
require "containable"
|
436
434
|
|
437
435
|
module CustomContainer
|
438
|
-
extend
|
436
|
+
extend Containable
|
439
437
|
|
440
438
|
register :echo, -> result { result }
|
441
|
-
register
|
439
|
+
register :insert, Pipeable::Steps::Insert
|
442
440
|
end
|
443
441
|
|
444
|
-
include Pipeable
|
442
|
+
include Pipeable[CustomContainer]
|
445
443
|
|
446
444
|
pipe :a, echo, insert(:b)
|
447
445
|
|
448
446
|
# Yields: Success [:a, :b]
|
449
447
|
----
|
450
448
|
|
451
|
-
The above is a hybrid example where the `CustomContainer` registers a custom `echo` step along with the default `insert` step to make a new container. This is included when passed in as an argument via `.
|
449
|
+
The above is a hybrid example where the `CustomContainer` registers a custom `echo` step along with the default `insert` step to make a new container. This is included when passed in as an argument via `.[]` (i.e. `include Pipeable[CustomContainer]`).
|
452
450
|
|
453
451
|
Whether you use default, custom, or hybrid steps, you have maximum flexibility using this approach.
|
454
452
|
|
@@ -479,7 +477,7 @@ bin/console
|
|
479
477
|
The architecture of this gem is built on top of the following concepts and gems:
|
480
478
|
|
481
479
|
* {function_composition_link}: Made possible through the use of the `\#>>` and `#<<` methods on the link:https://rubyapi.org/3.1/o/method[Method] and link:https://rubyapi.org/3.1/o/proc[Proc] objects.
|
482
|
-
* {
|
480
|
+
* {containable_link}: Allows related dependencies to be grouped together for injection as desired.
|
483
481
|
* {dry_monads_link}: Critical to ensuring the entire pipeline of steps adhere to the {railway_pattern_link} and leans heavily on the `Result` object.
|
484
482
|
* link:https://alchemists.io/projects/marameters[Marameters]: Through the use of the `.categorize` method, dynamic message passing is possible by inspecting the operation method's parameters.
|
485
483
|
|
@@ -4,15 +4,15 @@ require "dry/monads"
|
|
4
4
|
require "refinements/array"
|
5
5
|
|
6
6
|
module Pipeable
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# Defines the pipe and and associated step methods for an object.
|
8
|
+
class Definer < Module
|
9
9
|
include Dry::Monads[:result]
|
10
10
|
|
11
11
|
using Refinements::Array
|
12
12
|
|
13
|
-
def initialize
|
13
|
+
def initialize container = Steps::Container, pipe: Pipe
|
14
14
|
super()
|
15
|
-
@
|
15
|
+
@container = container
|
16
16
|
@pipe = pipe
|
17
17
|
@instance_module = Class.new(Module).new
|
18
18
|
end
|
@@ -26,22 +26,20 @@ module Pipeable
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
attr_reader :
|
30
|
-
|
31
|
-
def define_pipe
|
32
|
-
local_pipe = pipe
|
29
|
+
attr_reader :container, :pipe, :instance_module
|
33
30
|
|
31
|
+
def define_pipe pipeline = pipe
|
34
32
|
instance_module.define_method :pipe do |input, *steps|
|
35
33
|
steps.each { |step| steps.supplant step, method(step) if step.is_a? Symbol }
|
36
|
-
|
34
|
+
pipeline.call(input, *steps)
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
38
|
def define_steps
|
41
|
-
instance_module.class_exec
|
42
|
-
|
39
|
+
instance_module.class_exec container do |dependencies|
|
40
|
+
dependencies.each_key do |name|
|
43
41
|
define_method name do |*positionals, **keywords, &block|
|
44
|
-
step =
|
42
|
+
step = dependencies[name]
|
45
43
|
step.is_a?(Proc) ? step : step.new(*positionals, **keywords, &block)
|
46
44
|
end
|
47
45
|
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "containable"
|
4
4
|
|
5
5
|
module Pipeable
|
6
6
|
module Steps
|
7
7
|
# Registers default steps.
|
8
8
|
module Container
|
9
|
-
extend
|
9
|
+
extend Containable
|
10
10
|
|
11
|
-
register
|
12
|
-
register
|
13
|
-
register
|
14
|
-
register
|
15
|
-
register
|
16
|
-
register
|
17
|
-
register
|
18
|
-
register
|
19
|
-
register
|
20
|
-
register
|
21
|
-
register
|
22
|
-
register
|
23
|
-
register
|
11
|
+
register :as, As
|
12
|
+
register :bind, Bind
|
13
|
+
register :check, Check
|
14
|
+
register :fmap, Fmap
|
15
|
+
register :insert, Insert
|
16
|
+
register :map, Map
|
17
|
+
register :merge, Merge
|
18
|
+
register :orr, Or
|
19
|
+
register :tee, Tee
|
20
|
+
register :to, To
|
21
|
+
register :try, Try
|
22
|
+
register :use, Use
|
23
|
+
register :validate, Validate
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/pipeable.rb
CHANGED
@@ -10,11 +10,16 @@ end
|
|
10
10
|
|
11
11
|
# Main namespace.
|
12
12
|
module Pipeable
|
13
|
-
def self.included(descendant) = descendant.include
|
13
|
+
def self.included(descendant) = descendant.include Definer.new
|
14
14
|
|
15
15
|
def self.loader registry = Zeitwerk::Registry
|
16
16
|
@loader ||= registry.loaders.find { |loader| loader.tag == File.basename(__FILE__, ".rb") }
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.
|
19
|
+
def self.[](container) = Definer.new(container)
|
20
|
+
|
21
|
+
def self.with(...)
|
22
|
+
warn "`#{self.class}.#{__method__}` is deprecated, use `.[]` instead.", category: :deprecated
|
23
|
+
Definer.new(...)
|
24
|
+
end
|
20
25
|
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 = "0.
|
5
|
+
spec.version = "0.2.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/pipeable"
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
24
24
|
|
25
25
|
spec.required_ruby_version = "~> 3.3"
|
26
|
-
spec.add_dependency "
|
26
|
+
spec.add_dependency "containable", "~> 0.0"
|
27
27
|
spec.add_dependency "dry-monads", "~> 1.6"
|
28
28
|
spec.add_dependency "marameters", "~> 3.2"
|
29
29
|
spec.add_dependency "refinements", "~> 12.1"
|
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: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,22 +35,22 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2024-
|
38
|
+
date: 2024-04-03 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name:
|
41
|
+
name: containable
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.0'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.0'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: dry-monads
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,8 +120,8 @@ files:
|
|
120
120
|
- README.adoc
|
121
121
|
- lib/pipeable.rb
|
122
122
|
- lib/pipeable/composable.rb
|
123
|
+
- lib/pipeable/definer.rb
|
123
124
|
- lib/pipeable/pipe.rb
|
124
|
-
- lib/pipeable/stepable.rb
|
125
125
|
- lib/pipeable/steps/abstract.rb
|
126
126
|
- lib/pipeable/steps/as.rb
|
127
127
|
- lib/pipeable/steps/bind.rb
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
|
-
rubygems_version: 3.5.
|
167
|
+
rubygems_version: 3.5.7
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: An implementation of the Railway Pattern for functional composable pipelines.
|
metadata.gz.sig
CHANGED
Binary file
|