class Marsdawn::Util

Public Class Methods

adapter(namespace, class_name, base_path) click to toggle source
# File lib/marsdawn/util.rb, line 32
def self.adapter namespace, class_name, base_path
  unless namespace.const_defined?(class_name, false)
    require File.join(base_path, class_to_underscore(class_name))
  end
  namespace.const_get(class_name)
end
attr_escape(str) click to toggle source
# File lib/marsdawn/util.rb, line 28
def self.attr_escape str
  str.gsub(/"/, '\"')
end
class_to_underscore(class_name) click to toggle source
# File lib/marsdawn/util.rb, line 16
def self.class_to_underscore class_name
    class_name.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr('-','_').downcase
end
hash_symbolize_keys(hash, deep=false) click to toggle source
# File lib/marsdawn/util.rb, line 5
def self.hash_symbolize_keys hash, deep=false
  hash.each_with_object({}) do |(key, val), ret|
    val = hash_symbolize_keys(val, deep) if deep && val.kind_of?(Hash)
    ret[key.to_sym] = val
  end
end
hash_symbolize_keys_deep(hash) click to toggle source
# File lib/marsdawn/util.rb, line 12
def self.hash_symbolize_keys_deep hash
  hash_symbolize_keys hash, true
end
html_escape(str) click to toggle source
# File lib/marsdawn/util.rb, line 24
def self.html_escape str
  CGI.escapeHTML str
end
strip_tags(text) click to toggle source
# File lib/marsdawn/util.rb, line 20
def self.strip_tags text
  text.gsub(/<[^>]*>/ui, '')
end