lib/core/facets/string/pathize.rb in facets-2.8.4 vs lib/core/facets/string/pathize.rb in facets-2.9.0.pre.1

- old
+ new

@@ -1,26 +1,28 @@ class String - # Converts a (class or module) name to a unix path. + # Converts a camelcase name (e.g. class or module name) to a unix path. # - # My::CoolClass.name.pathize #=> "my/cool_class" + # "ExamplePathize".pathize #=> "example_pathize" + # "ExamplePathize::Example".pathize #=> "example_pathize/example" # + def pathize + gsub(/([A-Z]+)([A-Z])/,'\1_\2'). + gsub(/([a-z])([A-Z])/,'\1_\2'). + gsub('__','/'). + gsub('::','/'). + downcase + end + #-- - # Rails definition: + # Rails definition ... # # gsub(/__/, '/'). # gsub(/::/, '/'). # gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). # gsub(/([a-z\d])([A-Z])/,'\1_\2'). # tr("-", "_"). # downcase #++ - def pathize - gsub(/([A-Z]+)([A-Z])/,'\1_\2'). - gsub(/([a-z])([A-Z])/,'\1_\2'). - gsub('__','/'). - gsub('::','/'). - downcase - end end