Build Status Software License Release Last Release Github commits (since latest release) Last Commit WSRubyGems

Cmessages

A simple gem for outputting console errors/warnings/success/info messages.

The gem has 4 key exposed functions.

Function Purpose Default
error Display an error message light red text with an [ Error ] prefix
warning Display a warning message light yellow text with an [ Warning ] prefix
success Display a success message light green text with an [ Success ] prefix
info Display an info message light cyan text with an [ Info ] prefix

It is possible to disable colour, disable prefixed, define custom colours and custom prefixes.

Installation

Add this line to your application's Gemfile:

gem 'cmessages'

And then execute:

bundle install

Or install it yourself as:

gem install cmessages

Usage

Default Users

cm = Cmessages.new()

cm.error('This is an error message')
cm.warning('This is a warning warning')
cm.success('This is a success message')
cm.info('This is an info message')

It is also possible to chain the functions.

message='This is an error message'
message.error

Advanced Usage

It is possible to pass configuration when creating a new instance of cmessages.

cm = Cmessages.new(use_prefixes => false)
cm.error('This is an error with no prefix')

or

message='This is an error message'
message.error(use_prefixes => false)

Configuration Options

Name Purpose Default
:error_colour Set the colour for an error message :light_red
:warning_colour Set the colour for a warning message :light_yellow
:success_colour Set the colour for a warning message :light_green
:info_colour Set the colour for an info message :light_cyan
:error_prefix Set the colour for an error message '[ Error ]'
:warning_prefix Set the colour for a warning message '[ Warning ]'
:success_prefix Set the colour for a warning message '[ Success ]'
:info_prefix Set the colour for an info message '[ Info ]'
:use_colours Should we use colour in the output true
:use_prefixes Should we use prefies in the output true

Valid Colours

Default Colour Highlighted Colour
:black :light_black
:red :light_red
:green :light_green
:yellow :light_yellow
:blue :light_blue
:magenta :light_magenta
:cyan ;light_cyan
:white :light_white
:default N/A

Note: If you use an invalid colour, it will not error, it will simply use the default colour instead.

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.

Testing

For local testing make sure that you run bundle exec rspec spec and then rake install to install the gem locally.

For further information please refer to the contributing documentation.