Project

banzai

0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Toolkit for processing input using filters and pipelines
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.3.0
~> 0.53.0
~> 0.9.12
 Project Readme

Banzai

Simple toolkit for processing input using filter/pipeline concept.

Installation

Add this line to your application's Gemfile:

gem 'banzai'

Usage

First, implement some filters:

class GaussianBlur < Banzai::Filter
  def call(input)
    # process input
    # ...
  end
end 

class Nostalgia < Banzai::Filter
  def call(input)
    # process input
    # ...
  end
end

Then you can apply them to some input:

GaussianBlur.new(radius:1.1).call(image)

You can also use class method call if filter doesn't have options, or you want to apply default ones (defined in implementation itself):

Nostalgia.call(image)

To apply multiple filters to input use Banzai::Pipeline. Note that you can combine filter class and it's instances:

blurred_effect = Banzai::Pipeline.new(GaussianBlur.new(radius:1.1), Nostalgia)
blurred_effect.call(image)

Banzai::Pipeline is just another filter, so you can mix them with filters into a new pipeline:

Banzai::Pipeline.new(blurred_effect, RoundCorners.new(radius:0.87))

Working Example

Here's a simple working example:

class StripFilter < Banzai::Filter
  def call(input)
    input.strip
  end
end

class UpcaseFilter < Banzai::Filter
  def call(input)
    input.upcase
  end
end

pipeline = Banzai::Pipeline.new(StripFilter, UpcaseFilter)
puts pipeline.call('    ohai ') # prints "OHAI"

Contributing

Open a pull request but first make sure this is green:

bundle exec rake

Code status

Circle CI

Licence

Banzai is released under the MIT License.