lib/retrospec.rb in retrospec-0.4.0 vs lib/retrospec.rb in retrospec-0.5.0
- old
+ new
@@ -1,11 +1,24 @@
-require_relative 'version'
+require_relative 'retrospec/version'
# monkey patch in some color effects string methods
class String
def red; "\033[31m#{self}\033[0m" end
def green; "\033[32m#{self}\033[0m" end
def cyan; "\033[36m#{self}\033[0m" end
def yellow; "\033[33m#{self}\033[0m" end
def warning; yellow end
def fatal; red end
def info; green end
+
+ def camel_case
+ return self if self !~ /_/ && self =~ /[A-Z]+.*/
+ split('_').map(&:capitalize).join
+ end
+
+ def underscore
+ self.gsub(/::/, '/').
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
+ tr("-", "_").
+ downcase
+ end
end
\ No newline at end of file