Sha256: 58510cab6e63541365a234baa2d0379da9cbc7e03968d0d941fe142ab2668dc0

Contents?: true

Size: 1.18 KB

Versions: 38

Compression:

Stored size: 1.18 KB

Contents

class String
  def squish!
    strip!
    gsub!(/\s+/, ' ')
    self
  end
  def squish
    dup.squish!
  end
  def underscore!
    self unless /[A-Z-]|::/.match?(self)
    self.to_s.gsub!("::".freeze, "/".freeze)
    self.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
    self.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
    self.tr!("-".freeze, "_".freeze)
    self.downcase!
    self
  end
  def underscore
    dup.underscore!
  end
  def camelcase!
    to_s.scan(/\w+/).collect(&:capitalize).join
  end
  def camelcase
    dup.camelcase!
  end
  def camelize!
    to_s.split(/_|\s+/).collect(&:capitalize).join
  end
  def camelize
    dup.camelize!
  end
  def safe_log_name
    self.split('::').last.underscore
  end
end
module SiteHook
  module StrExt
    def StrExt.mkvar(inspection)
      inspection.to_s.tr('.', '_').tr(' ', '_')
    end
    def StrExt.mkatvar(inspection)
      inspection.dup.to_s.insert(0, '@').to_sym
    end
    def StrExt.mkatatvar(inspection)
      inspection.to_s.insert(0, '@').insert(0, '@').to_sym
    end
    def StrExt.rematvar(inspection)
      inspection.to_s.tr('@', '')
    end

    def self.mkmvar(inspection)
      inspection.to_s.tr('@', '').to_sym
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
site_hook-1.0.22 lib/site_hook/string_ext.rb
site_hook-1.0.21 lib/site_hook/string_ext.rb
site_hook-1.0.20 lib/site_hook/string_ext.rb
site_hook-1.0.19 lib/site_hook/string_ext.rb
site_hook-1.0.18 lib/site_hook/string_ext.rb
site_hook-1.0.17 lib/site_hook/string_ext.rb
site_hook-1.0.16 lib/site_hook/string_ext.rb
site_hook-1.0.15 lib/site_hook/string_ext.rb
site_hook-1.0.14 lib/site_hook/string_ext.rb
site_hook-1.0.13 lib/site_hook/string_ext.rb
site_hook-1.0.12 lib/site_hook/string_ext.rb
site_hook-1.0.11 lib/site_hook/string_ext.rb
site_hook-1.0.10 lib/site_hook/string_ext.rb
site_hook-1.0.9 lib/site_hook/string_ext.rb
site_hook-1.0.8 lib/site_hook/string_ext.rb
site_hook-1.0.7 lib/site_hook/string_ext.rb
site_hook-1.0.6 lib/site_hook/string_ext.rb
site_hook-1.0.5 lib/site_hook/string_ext.rb
site_hook-1.0.4 lib/site_hook/string_ext.rb
site_hook-1.0.3 lib/site_hook/string_ext.rb