The project is in a healthy, maintained state
A Ruby library for functional pipeline composition with conditional steps, side effects via tee, and built-in error handling for clean data transformations.
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

philiprehberger-pipe

Gem Version Tests License

Functional pipeline composition with conditional steps and error handling for Ruby.

Requirements

  • Ruby >= 3.1

Installation

Add to your Gemfile:

gem 'philiprehberger-pipe'

Or install directly:

gem install philiprehberger-pipe

Usage

require 'philiprehberger/pipe'

result = Philiprehberger::Pipe.new(10)
  .step { |v| v + 5 }
  .step { |v| v * 2 }
  .value
# => 30

Conditional Steps

Philiprehberger::Pipe.new(user_input)
  .step(if: ->(v) { v.is_a?(String) }) { |v| v.strip }
  .step(unless: ->(v) { v.empty? }) { |v| v.downcase }
  .value

Side Effects with Tee

Philiprehberger::Pipe.new(data)
  .step { |v| transform(v) }
  .tee { |v| logger.info("Transformed: #{v}") }
  .step { |v| finalize(v) }
  .value

Error Handling

Philiprehberger::Pipe.new(raw_input)
  .step { |v| parse(v) }
  .step { |v| validate(v) }
  .on_error { |e| default_value }
  .value

API

Method Description
Pipe.new(initial_value) Create a new pipeline with a starting value
#step(if: nil, unless: nil, &block) Add a transformation step with optional guards
#tee(&block) Add a side-effect step (value passes through unchanged)
#on_error(&block) Set an error handler for the pipeline
#value Execute the pipeline and return the final result

Development

bundle install
bundle exec rspec      # Run tests
bundle exec rubocop    # Check code style

License

MIT