Core
Provides a collection of common objects missing from core Ruby. This allows you to reduce duplication, improve performance, and improve memory usage in order to engineer advanced architectures.
- Features
- Requirements
- Setup
- Usage
- Constants
- Functions
- Modules
- Development
- Tests
- License
- Security
- Code of Conduct
- Contributions
- Developer Certificate of Origin
- Versions
- Community
- Credits
Features
-
Provides commonly needed core objects.
Requirements
-
Ruby.
Setup
To set up the project, run:
bin/setupUsage
The following details what is currently available for use.
Constants
The following empty constants are frozen by default and available for use as core objects for use throughout your application.
-
Core::EMPTY_ARRAY: Provides an empty Array instance. -
Core::EMPTY_DATA: Provides an empty Data instance. -
Core::EMPTY_HASH: Provides an empty Hash instance. -
Core::EMPTY_SET: Provides an empty Set instance. -
Core::EMPTY_STRING: Provides an empty String instance. -
Core::EMPTY_STRUCT: Provides an empty Struct instance.
Functions
The following identity function (lambda) is available as a neutral value in Function Composition:
Core::Identity.call "example" # "example"Modules
A Composable module is available to you should you need to use Function Composition in order to make your objects composable via procs, lambdas, methods, and/or classes. Pairs well with the Pipeable gem. The module provides the following methods for you:
-
>>: Forward composition. -
<<: Backward composition. -
#call: The primary method to implement in order to be composable. Fails with aNoMethodErrorif not implemented.
To use, include Composable and implement #call as follows:
class Greeter
include Core::Composable
def initialize salutation = "Hi"
@salutation = salutation
end
def call(text) = "#{salutation} #{text}"
private
attr_reader :salutation
endThe above then allows you to compose your objects as functional pipelines:
appender = -> text { "#{text} -- An example of function composition." }
greeter = Greeter.new
(greeter >> appender).call "visitor"
# "Hi visitor -- An example of function composition."Development
To contribute, run:
git clone https://github.com/bkuhlmann/core
cd core
bin/setupYou can also use the IRB console for direct access to all objects:
bin/consoleTests
To test, run:
bin/rakeCredits
-
Built with Gemsmith.
-
Engineered by Brooke Kuhlmann.