UPDATE, March 2023: Here's an approach that is far simpler and less hacky, and achieves nearly the same thing: https://www.gregnavis.com/articles/elixir-style-pipelines-in-9-lines-of-ruby.html
UPDATE, May 2022: I have removed this gem from RubyGems. I've changed my mind and I no longer think this syntax is helpful. In fact, it can easily become a source of confusion and bugs. So I'm no longer maintaining this gem.
Pipeful makes it easy to pipe data through functions (callable objects). Just write the function classes and then chain them with the >>
operator:
extend Pipeful
'C:\test.txt' >> LoadFromFile >> ProcessData >> OutputResult(STDOUT)
See pipeful_test.rb
for examples.
For the story of how this gem came to be, see Functional programming techniques in Ruby.
Still, if you want to use the gem, you can add this line to your application's Gemfile:
gem "pipeful", :git => "git://github.com/fpsvogel/pipeful.git"
And then execute:
$ bundle install
Bug reports and pull requests are welcome on GitHub at https://github.com/fpsvogel/pipeful.
The gem is available as open source under the terms of the MIT License.