wilddima / pipeline_ruby

Simple pipeline operator for ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pipeline_ruby

<img src=“https://travis-ci.org/WildDima/pipeline_ruby.svg?branch=master” alt=“Build Status” />

Simple pipeline operator for ruby

Installation

Add this line to your application’s Gemfile:

gem 'pipeline_ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pipeline_ruby

Usage

class Test
  include Pipeline

  def upcase(arg)
    arg.upcase
  end

  def split(arg)
    arg.split
  end

  def reverse(arg)
    arg.reverse
  end

  def join(arg)
    arg.join
  end

  def call(arg)
    # Instead of this:
    # join(
    #   reverse(
    #     split(
    #       upcase(arg)
    #     )
    #   )
    # )
    # We can use it like this:
    pipeline(arg) do
      upcase >> split >> reverse >> join
    end
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at github.com/wild_dima/pipeline_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.

License

The gem is available as open source under the terms of the [MIT License](opensource.org/licenses/MIT).

About

Simple pipeline operator for ruby

License:MIT License


Languages

Language:Ruby 98.1%Language:Shell 1.9%