Sha256: 28327291404c81bbe3199c42aebf0ddaf416bf5179a90dd7dc8f3ba5f83fb695

Contents?: true

Size: 851 Bytes

Versions: 4

Compression:

Stored size: 851 Bytes

Contents

# Returns a formatted JSON string.
#
# @param json [String] JSON string to format
# @param indent [String] indent that used in formatting
# @return [String] prettier form of the given JSON string
def pj(json, indent = ' ')
  require 'json'
  JSON.pretty_generate(json, :indent => indent * 4).gsub!(/\n/, '<br/>')
end

# Output info message to console.
#
# @param msg [String] message to output
def puts_info(msg)
  $stdout.puts "\e[32m[INFO] #{msg}\e[0m" if Calamum::Config[:debug]
end

# Output warning message to console.
#
# @param msg [String] message to output
def puts_warning(msg)
  $stdout.puts "\e[33m[WARNING] #{msg}\e[0m" if Calamum::Config[:debug]
end

# Output error message to console.
#
# @param msg [String] message to output
def puts_error(msg)
  $stderr.puts "\e[31m[ERROR] #{msg}\e[0m" if Calamum::Config[:debug]
  exit(1)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
calamum-1.2.2 lib/calamum/helpers.rb
calamum-1.2.1 lib/calamum/helpers.rb
calamum-1.2.0 lib/calamum/helpers.rb
calamum-1.1.0 lib/calamum/helpers.rb