core 3.3.0 → 3.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 550649438a79452183f1641126bdb0e1a66fec5562ba85ddac55ff9c2964c76a
4
- data.tar.gz: 8c49c211d08d6383b76f3b3027b09b393ef305564e32febf71eedfaa0ffc4a17
3
+ metadata.gz: 34e053097ae6807acaccbceda960d36c0fab5727d1c4fd44b27d920a38d04e17
4
+ data.tar.gz: 0e8e8efa4f28893e6fe3b2319287ca999c5cf8551d13d9533b009b67c51f5863
5
5
  SHA512:
6
- metadata.gz: 5233ea35a55b2923e00140869a3fab08e9ddd9529d3194214c8fe7861f2b6baf5a18549f6f3af4149a56db93474cac57eaf93692f8803cf6f913af7f5dbf5134
7
- data.tar.gz: 00021ad5c7c443d7fd0650d4c53005c4f9bad396076e707d3dcfcad0ec2702a2dec700e788b22a6fb60cfe79ea00b618f034077c75ec2cd333a7f03fa171a09d
6
+ metadata.gz: a1a1899d72683603248cb2a5690e3bd228352ea6f891a2e51f757ff2b1c01179178448c33be10c9218d24241b70ce1e9e9e6b3e5b8015281e912fefd0b1ed563
7
+ data.tar.gz: 7c1d341c9fdddc3e407e8d4aaec01e3e8b1cb2281bb9082922af73740acfbb2a5b4a93724b827f8400ceb75f6c5175e686d7c9b032558c90b3b8ff016f14d54e
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -2,9 +2,13 @@
2
2
  :toclevels: 5
3
3
  :figure-caption!:
4
4
 
5
+ :ruby_link: link:https://www.ruby-lang.org[Ruby]
6
+ :function_composition_link: link:https://alchemists.io/articles/ruby_function_composition[Function Composition]
7
+ :pipeable_link: link:https://alchemists.io/projects/pipeable[Pipeable]
8
+
5
9
  = Core
6
10
 
7
- Provides a collection of core objects missing from the standard Ruby distribution. This is meant to provide common objects for engineering advanced architctures in order to reduce duplication, improve performance, and improve memory usage.
11
+ Provides a collection of common objects missing from core {ruby_link}. This allows you to reduce duplication, improve performance, and improve memory usage in order to engineer advanced architectures.
8
12
 
9
13
  toc::[]
10
14
 
@@ -14,7 +18,7 @@ toc::[]
14
18
 
15
19
  == Requirements
16
20
 
17
- . link:https://www.ruby-lang.org[Ruby].
21
+ . {ruby_link}.
18
22
 
19
23
  == Setup
20
24
 
@@ -42,13 +46,52 @@ The following _empty_ constants are frozen by default and available for use as c
42
46
 
43
47
  === Functions
44
48
 
45
- The following identity function (lambda) is available as a neutral value in link:https://alchemists.io/articles/ruby_function_composition[function composition]:
49
+ The following identity function (lambda) is available as a neutral value in {function_composition_link}:
46
50
 
47
51
  [source,ruby]
48
52
  ----
49
53
  Core::Identity.call "example" # "example"
50
54
  ----
51
55
 
56
+ === Modules
57
+
58
+ A `Composable` module is available to you should you need to use {function_composition_link} in order to make your objects composable via procs, lambdas, methods, and/or classes. Pairs well with the {pipeable_link} gem. The module provides the following methods for you:
59
+
60
+ * `+>>+`: Forward composition.
61
+ * `+<<+`: Backward composition.
62
+ * `+#call+`: The primary method to implement in order to be composable. Fails with a `NoMethodError` if not implemented.
63
+
64
+ To use, include `Composable` and implement `#call` as follows:
65
+
66
+ [source,ruby]
67
+ ----
68
+ class Greeter
69
+ include Core::Composable
70
+
71
+ def initialize salutation: "Heya"
72
+ @salutation = salutation
73
+ end
74
+
75
+ def call(text) = "#{salutation} #{text}"
76
+
77
+ private
78
+
79
+ attr_reader :salutation
80
+ end
81
+ ----
82
+
83
+ The above then allows you to compose your objects as functional pipelines:
84
+
85
+ [source,ruby]
86
+ ----
87
+ appender = -> text { "#{text} -- An example of function composition."}
88
+ greeter = Greeter.new
89
+
90
+ (greeter >> appender).call "visitor"
91
+
92
+ # "Heya visitor -- An example of function composition."
93
+ ----
94
+
52
95
  == Development
53
96
 
54
97
  To contribute, run:
data/core.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "core"
5
- spec.version = "3.3.0"
5
+ spec.version = "3.4.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/core"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Core
4
+ # Allows objects to be functionally composable.
5
+ module Composable
6
+ def >>(other) = method(:call) >> other
7
+
8
+ def <<(other) = method(:call) << other
9
+
10
+ def call = fail NoMethodError, "`#{self.class.name}##{__method__}` must be implemented."
11
+ end
12
+ end
data/lib/core.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "core/composable"
3
4
  require "core/identity"
4
5
 
5
6
  # Main namespace.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -47,6 +47,7 @@ files:
47
47
  - README.adoc
48
48
  - core.gemspec
49
49
  - lib/core.rb
50
+ - lib/core/composable.rb
50
51
  - lib/core/identity.rb
51
52
  homepage: https://alchemists.io/projects/core
52
53
  licenses:
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  requirements: []
76
- rubygems_version: 4.0.15
77
+ rubygems_version: 4.0.20
77
78
  specification_version: 4
78
79
  summary: A collection of foundational objects.
79
80
  test_files: []
metadata.gz.sig CHANGED
Binary file