Skip to content

tareksamni/bitmap_editor

Repository files navigation

Bitmap Editor Technical Test

This is a ruby implementation of technical test called Bitmap Editor which can be found here. The code in this repo is mainly divided into small/simple classes and each class own its responsibilities, errors, constants, state and behaviour as follows:

  • BitmapEditor is responsible for proxing users input to the Bitmap object, mainly using a command parser object.

  • Command is responsible for parsing the user input and encapsulate the command parts (Type, coordinates and colour) and it also validates the user input to make sure that a user is trying a valid command with valid params.

  • Bitmap is responsible for handling the bitmap structure and different operations to be applied on bitmap like (initialize new bitmap, color a given pixel, color a given vertical/horizontal segment, etc.). Bitmap is also handling how a bitmap should be shown on a user terminal.

  • Pixel is just a simple class structure to define allowed colours that a pixel can accept and how a pixel can be represented on a user terminal.

This project is following TDD so specs are always set before feature coding.

Setup & Run

This project is using:

  • ruby 2.3.1
  • bundler gem to install all required gems that are listed in Gemfile.
  • rspec gem as the tests framework. Config can be found in .rspec.
  • rubocop gem as a main codeing style guide. Config can be found in .rubocop.yml.
  • Docker to run the application without any dependecies using docker engine.

Using Docker (Build from soruce)

Install Docker Engine on your machine to be able to follow these steps.

run docker --version to make sure that docker is installed and running successfully. You should get a message like Docker version 1.12.3, build 6b644ec. Now you follow these steps:

  • Build docker image from source
docker build . -t bitmap_editor:latest_git_commit_sha

where latest_git_commit_sha is the git current checked out git commit SHA.

  • Run the application on a docker container
docker run -it bitmap_editor:target_git_commit_sha "ruby runner.rb"
  • Run tests on a docker container
docker run -it bitmap_editor:target_git_commit_sha "rspec"

Using Docker (Pull from docker hub)

Install Docker Engine on your machine to be able to follow these steps.

run docker --version to make sure that docker is installed and running successfully. You should get a message like Docker version 1.12.3, build 6b644ec. Now you follow these steps:

  • Run the application on a docker container
docker run -it tareksamni/bitmap_editor:latest "ruby runner.rb"
  • Run tests on a docker container
docker run -it tareksamni/bitmap_editor:latest "rspec"

Without Docker

You need to install the dependecies first, follow these steps to install all required dependencies using RVM:

  • Install RVM
$ curl -sSL https://get.rvm.io | bash -s stable
  • Install/Use ruby 2.3.1 and create a gemset for this project
$ rvm use ruby-2.3.1@bitmap_editor --create
  • Install bundler gem
$ gem install bundler
  • Install gems listed in Gemfile
$ bundle install
  • Run application
$ ruby runner.rb
  • Run tests
$ rspec

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •