Colorate
Colorate exposes simple color methods that allow you to color output sent to the console. For an explanation on how to use the gem, please refer to 'Usage' below.
Installation
Add this line to your application's Gemfile:
gem 'colorate'
And then execute:
$ bundle
Or install it yourself as:
$ gem install colorate
Usage
In short, Colorate accepts a named color as a method, together with a hash of options that can set the text to bold and/or underlined. This is easiest shown by examples.
Colorate.red('Hello World!')
Colorate.blue('A second argument consists of a hash', bold: true)
Colorate.cyan('The only keys are bold and underline and both are booleans', underline: true)
Colorate.purple('So there!', bold: true, underline: true)
Colorate only responds to the following method calls:
black
blue
green
cyan
red
purple
brown
light_gray
dark_gray
light_blue
light_green
light_cyan
light_red
light_purple
yellow
white
PLEASE NOTE: These methods only return 'decorated' strings. They do not, themselves, output anything to the console. This was done as a matter of design so that different colored elements can easily be combined, but please leave a comment if you think a different approach makes more sense.
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/radiofreemattd/colorize. 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.