Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

banzai

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

banzai

  • 0.1.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 09 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc