BinaryTransformer

Interface and executor for a transformers to transform byte arrays in a pipeline-based design programmatically in ruby.

This can be used to parse text blobs, resize image, compress music, encode video... etc

Currently, these binaries are available:

  • NONE

Installation

Add this line to your application's Gemfile:

gem 'binary_transformer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install binary_transformer

Usage

Using transformers

Assuming you have a few image transformers
ImageCompressor that compress images,
ImageResizer that resizes images,
Sepia that converts image to sepia,
and Blur that blurs the image
which all implements the BinaryTransformer::Transformer interface, the usage is as follows:

# Transformer instances
compressor = ImageCompressor.new
resize = ImageResizer.new
sepia = SepiaTransformer.new
blur = BlurTransformer.new
# Obtain Binary
binary IO.binread "image.png"

# Extend the binary
binary.extend StreamLike

# Pipe the binary through the transformers. Use >> to chain and >  for the last transformer
converted = binary >> compressor >> resize >> sepia > blur  

 # Write the binary back
 IO.binwrite "converted.png", converted 

Development

After cloning, run to install dependencies

$ bundle install

To run unit tests:

$ bundle exec rspec

Contributing

Bug reports and pull requests are welcome on GitLab at https://gitlab.com/ruby-gem/binary-transformer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the BinaryTransformer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.