lib/hammer_cli/utils.rb in hammer_cli-0.1.3 vs lib/hammer_cli/utils.rb in hammer_cli-0.1.4

- old
+ new

@@ -22,9 +22,19 @@ def indent_with(indent_str) gsub(/^/, indent_str) end + def underscore + word = self.dup + word.gsub!(/::/, '/') + word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') + word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') + word.tr!("-", "_") + word.downcase! + word + end + def constantize raise NameError, "Can't constantize empty string" if self.empty? HammerCLI.constant_path(self)[-1] end