class Shacho::Util

Public Class Methods

camelize(string) click to toggle source

again, shamelessly ripped from active_support

# File lib/shacho/util.rb, line 15
def self.camelize(string)
  string.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end
constantize(camel_cased_word, constant) click to toggle source

shamelessly ripped from active_support

# File lib/shacho/util.rb, line 4
def self.constantize(camel_cased_word, constant)
  names = camel_cased_word.split('::')
  names.shift if names.empty? || names.first.empty?

  names.each do |name|
    constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
  end
  constant
end
help() click to toggle source

TODO make less horrible

# File lib/shacho/util.rb, line 20
def self.help
  puts "USAGE"
  puts "  shacho action params"
  puts
  puts "  where `action` is one of the standard CRUDy actions: "
  puts "    create"
  puts "    use"
  puts "    list"
  puts "    which"
  puts "    edit"
  puts "    remove"
  puts "    clear"
  puts
  puts "  `params` refers to any additional parmeters you might want to pass in."
  puts "  For now, that's just the name of the account"
  puts
  puts "EXAMPLES"
  puts "  shacho create default"
  puts "  shacho use default"
  puts "  shacho list"
  puts "  shacho which"
  puts "  shacho edit default"
  puts "  shacho remove default"
  puts "  shacho clear"
end