Sha256: 7150f49c9fe7f15f0b4fec18da767e33014a6a6a8dbcd2e6255b9a69819ae5ab

Contents?: true

Size: 518 Bytes

Versions: 31

Compression:

Stored size: 518 Bytes

Contents

module ActiveSupportMethods
  def camelize
    sub(/^([a-z])/) {$1.upcase}.gsub(/_([a-z])/) do
      $1.upcase
    end
  end
  
  # Source
  # http://github.com/rails/rails/blob/b600bf2cd728c90d50cc34456c944b2dfefe8c8d/activesupport/lib/active_support/inflector.rb
  def underscore
    gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
  end
end

String.send :include, ActiveSupportMethods unless String.new.respond_to?(:underscore)

Version data entries

31 entries across 31 versions & 4 rubygems

Version Path
andrewtimberlake-couch_potato-0.2.8.1 lib/core_ext/string.rb
andrewtimberlake-couch_potato-0.2.8.2 lib/core_ext/string.rb
andrewtimberlake-couch_potato-0.2.8.3 lib/core_ext/string.rb
andrewtimberlake-couch_potato-0.2.8.4 lib/core_ext/string.rb
langalex-couch_potato-0.2.11 lib/core_ext/string.rb
langalex-couch_potato-0.2.12 lib/core_ext/string.rb
langalex-couch_potato-0.2.8 lib/core_ext/string.rb
langalex-couch_potato-0.2.9 lib/core_ext/string.rb
couch_potato-0.2.27 lib/core_ext/string.rb
couch_potato-0.2.26 lib/core_ext/string.rb
couch_potato-0.2.25 lib/core_ext/string.rb
couch_potato-0.2.24 lib/core_ext/string.rb
couch_potato-0.2.23 lib/core_ext/string.rb
couch_tomato-0.2.0 lib/core_ext/string.rb
couch_potato-0.2.22 lib/core_ext/string.rb
couch_potato-0.2.21 lib/core_ext/string.rb
couch_potato-0.2.20 lib/core_ext/string.rb
couch_potato-0.2.19 lib/core_ext/string.rb
couch_potato-0.2.18 lib/core_ext/string.rb
couch_potato-0.2.17 lib/core_ext/string.rb