Sha256: 0aa842ed4e782f5022aa7062c73edd9941a3b08ac7bb2286fc4478508cc25bdb

Contents?: true

Size: 700 Bytes

Versions: 44

Compression:

Stored size: 700 Bytes

Contents

# encoding: utf-8

module Alchemy
  # Provides methods for converting names into urlnames and vice versa.
  #
  module NameConversions

    # Converts a given name into url save and readable urlanme.
    # Uses rails parameterize, but converts german umlauts before.
    #
    # @returns String
    def convert_to_urlname(name)
      name
        .gsub(/[äÄ]/, 'ae')
        .gsub(/[üÜ]/, 'ue')
        .gsub(/[öÖ]/, 'oe')
        .gsub(/[ß]/, 'ss')
        .parameterize
    end

    # Converts a filename and suffix into a human readable name.
    #
    def convert_to_humanized_name(name, suffix)
      name.gsub(/\.#{::Regexp.quote(suffix)}$/i, '').gsub(/_/, ' ').strip
    end

  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.3 lib/alchemy/name_conversions.rb
lc_alchemy_cms-3.2.1 lib/alchemy/name_conversions.rb
lc_alchemy_cms-3.2.0 lib/alchemy/name_conversions.rb
alchemy_cms-3.2.0 lib/alchemy/name_conversions.rb
alchemy_cms-3.2.0.rc1 lib/alchemy/name_conversions.rb
alchemy_cms-3.2.0.beta lib/alchemy/name_conversions.rb
alchemy_cms-2.9.1 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.1 lib/alchemy/name_conversions.rb
alchemy_cms-3.0.4 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.rc3 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.rc2 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.rc1 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.beta6 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.beta5 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.beta4 lib/alchemy/name_conversions.rb
alchemy_cms-3.0.3 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.beta3 lib/alchemy/name_conversions.rb
alchemy_cms-3.1.0.beta2 lib/alchemy/name_conversions.rb