Bitmap Compiler Build Status Gem Version Maintainability Test Coverage

This is the Bitmap compiler gem! It aims to build a bitmap given an input file.

You can check on spec/support folder to see examples. The supported commands are:

I M N       - Create a new M x N image with all pixels coloured white (O)
C           - Clears the table, setting all pixels to white (O)
L X Y C     - Colours the pixel (X,Y) with colour C
V X Y1 Y2 C - Draw a vertical segment of colour C in column X between rows Y1 and Y2 (inclusive)
H X1 X2 Y C - Draw a horizontal segment of colour C in row Y between columns X1 and X2 (inclusive)
S           - Show the contents of the current image
  • The maximum size allowed when creating an Image is 250x250
  • Colors must be a single capital character A-Z

Example of file

Input: show.txt

I 5 6 
L 1 3 A 
V 2 3 6 W 
H 3 5 2 Z 
S

Output

OOOOO
OOZZZ
AWOOO
OWOOO
OWOOO
OWOOO

Usage

Ruby console

You can use the application programmatically by installing the gem and using on the Ruby environment (You can run bin/console for this). If you want to test the Editor class after launching the console, just run:

BitmapCompiler::Core::Editor.new.run('spec/support/show.txt')

CLI

The application also has a CLI built-in that can be used directly on any *nix terminal.

$ bitmap_compiler process_file -f=spec/support/show.txt
$ bitmap_compiler process_file --file=spec/support/show.txt

Use the help command for more information.

$ bitmap_compiler help process_file

Rails

Add this line to your application's Gemfile:

gem 'bitmap_compiler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bitmap_compiler

After that you should be able to use the Editor class in your rails console or inside your application:

path = "Specify the file path"

BitmapCompiler::Core::Editor.new.run(path)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rspec spec to run the tests.

Contributing

See CONTRIBUTING.md.

License

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