0.0
No commit activity in last 3 years
No release in over 3 years
Print colorized strings on terminal (Useful for printing fancy logs)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Term::Colorizer

Gem Version Build Status

Print colorized strings on terminal (Useful for printing fancy logs)

Installation

Install gem by using following command:

gem install term-colorizer

or add it to your Gemfile as:

gem 'term-colorizer', require: 'term-colorizer'

Usage

"Duck can quack".green
# => "\e[32mDuck can quack\e[0m"

puts "Wow, that's really".underline + " cool ".black.strikethrough + "hot!".bg_red.bright_yellow
# guess what it will do?

To see all accessible methods provided by term-colorizer, use:

>> "Hello".term_colorizer_methods
=> [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :bright_black, :bright_red, :bright_green, :bright_yellow, :bright_blue, :bright_magenta, :bright_cyan, :bright_white, :bg_black, :bg_red, :bg_green, :bg_yellow, :bg_blue, :bg_magenta, :bg_cyan, :bg_white, :underline, :strikethrough, :term_colorizer_methods, :fancy_color_methods, :no_underline, :no_strikethrough, :no_color, :no_bg_color, :plain_text, :reset_fancyness]

To see available color methods only:

>> "Hello".color_methods
=> [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]

To see available bright (bold) color methods only:

>> "Hello".bright_color_methods
=> [:bright_black, :bright_red, :bright_green, :bright_yellow, :bright_blue, :bright_magenta, :bright_cyan, :bright_white]

To see available background color methods only:

>> "Hello".bg_color_methods
=> [:bg_black, :bg_red, :bg_green, :bg_yellow, :bg_blue, :bg_magenta, :bg_cyan, :bg_white]

Screenshots

term-colorizer-screenshot-1!

And, for sake -- also added bunch of reset methods, viz. plain_text, reset_fancyness, no_color, no_bg_color, no_underline, no_strikethrough. You can use 'em as:

>> "That's it, boy!".green.bg_yellow.plain_text
=> "That's it, boy!"

term-colorizer-screenshot-2!

😋

Contributing

You're encouraged to contribute to this gem.

  • Fork this project.
  • Make changes, write tests.
  • Report bugs, comment on and close open issues.
  • Updated CHANGELOG.
  • Make a pull request, bonus points for topic branches.

Copyright and License

Copyright (c) 2013, Vishal Telangre and Contributors. All Rights Reserved.

This project is licenced under the MIT License.