Sha256: ddc6281de675e67863a9326d357bd160f1d3018fe6fbf303db062eb9a2f2a4e6

Contents?: true

Size: 745 Bytes

Versions: 3

Compression:

Stored size: 745 Bytes

Contents

class Cistern::String
  # stolen from activesupport/lib/active_support/inflector/methods.rb, line 198
  def self.demodulize(path)
    path = path.to_s
    if i = path.rindex('::')
      path[(i+2)..-1]
    else
      path
    end
  end

  # stolen from activesupport/lib/active_support/inflector/methods.rb, line 90
  def self.underscore(camel_cased_word)
    return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
    word = camel_cased_word.to_s.gsub(/::/, '/')
    #word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1 && '_'}#{$2.downcase}" }
    word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
    word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
    word.tr!("-", "_")
    word.downcase!
    word
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cistern-0.12.3 lib/cistern/string.rb
cistern-0.12.2 lib/cistern/string.rb
cistern-0.12.1 lib/cistern/string.rb