Project

puts_utils

0.0
No commit activity in last 3 years
No release in over 3 years
Helpful utilities to puts in colour, tables and more.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0
~> 5.0
~> 10.0
~> 0.76
 Project Readme

PutsUtils

Prettier puts formatting for the lazy. Helpful utilities to puts in colour, tables and more.

Installation

Add the following line to your application's Gemfile:

gem 'puts_utils'

And then execute:

$ bundle 

Or install it yourself as:

$ gem install puts_utils

Usage

require 'puts_utils'

desc 'PutsUtils demo rake task'
task puts_utils_demo: do

  #
  # Include any of the PutsUtils modules you'd like
  #

  include PutsUtils::PutsColor
  include PutsUtils::PutsTable
  include PutsUtils::PutsPrompt

  #
  # Use puts_color to puts in various colors
  #

  puts_color 'Danger.', :red
  puts_color 'Done.', :green
  puts_color 'Warning.', :yellow
  puts_color 'Something.', :blue

  #
  # puts_color shorthand methods also available
  #

  puts_color_red 'Red'
  puts_color_purple 'Purple'
  puts_color_cyan 'Cyan'
  puts_color_gray 'Grey'
  puts_color_blue 'Blue'
  puts_color_yellow 'Yellow'
  puts_color_green 'Green'
  
  #
  # Use puts_prompt to ask for inputs
  #
  
  color = puts_prompt "What's your favourite colour?: ", required: true
  
  puts_color "You answered '#{color}'!", color.to_sym

  #
  # Use puts_table to display tabular data
  #
  
  puts_table %w[Color Code] do
    PutsUtils::PutsColor::COLOR_CODES.map do |color, code|
      [color, code]
    end
  end
end

License

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

Code of Conduct

Everyone interacting in the PutsUtils project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.