module StringHelpers
Public Class Methods
convert_to_app_name(value)
click to toggle source
convert a string to a valid Rails app name
# File lib/railsbricks/string_helpers.rb, line 16 def self.convert_to_app_name(value) if value.scan(/\_|\-/).size > 0 value.split(/\_|\-/).map(&:capitalize).join else value.slice(0,1).capitalize + value.slice(1..-1) end end
new_line(lines=1)
click to toggle source
simply displays empty lines
# File lib/railsbricks/string_helpers.rb, line 11 def self.new_line(lines=1) lines.times { puts } end
sanitize(value)
click to toggle source
replaces special characters with '_'
# File lib/railsbricks/string_helpers.rb, line 6 def self.sanitize(value) value.tr('^A-Za-z0-9', '_') end
wputs(text, highlight = :none)
click to toggle source
Wraps output text at 79 columns. Outputs in green if highlight = :info / red if :error / blue if :help
# File lib/railsbricks/string_helpers.rb, line 26 def self.wputs(text, highlight = :none) text = text.gsub(/\n/, ' ').gsub(/(.{1,#{79}})(\s+|$)/, "\\1\n").strip if highlight == :info puts UiHelpers.colorize(text, UiHelpers::GREEN) elsif highlight == :error puts UiHelpers.colorize(text, UiHelpers::RED) elsif highlight == :help puts UiHelpers.colorize(text, UiHelpers::BLUE) else puts text end end