Project

core

0.0
A long-lived project that still receives updates
A collection of foundational objects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

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.

Table of Contents
  • 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

  1. Ruby.

Setup

To set up the project, run:

bin/setup

Usage

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 a NoMethodError if 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
end

The 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/setup

You can also use the IRB console for direct access to all objects:

bin/console

Tests

To test, run:

bin/rake

Credits