Sha256: a1b5d6749719a7635b400022eda1e80a3027f43eced92c8aca8e6bd446d660b6

Contents?: true

Size: 706 Bytes

Versions: 47

Compression:

Stored size: 706 Bytes

Contents

# frozen_string_literal: true

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, "").tr("_", " ").strip
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
alchemy_cms-7.3.4 lib/alchemy/name_conversions.rb
alchemy_cms-7.3.3 lib/alchemy/name_conversions.rb
alchemy_cms-7.3.2 lib/alchemy/name_conversions.rb
alchemy_cms-7.2.7 lib/alchemy/name_conversions.rb
alchemy_cms-7.3.1 lib/alchemy/name_conversions.rb
alchemy_cms-7.3.0 lib/alchemy/name_conversions.rb
alchemy_cms-7.2.6 lib/alchemy/name_conversions.rb
alchemy_cms-7.2.5 lib/alchemy/name_conversions.rb
alchemy_cms-7.1.12 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.15 lib/alchemy/name_conversions.rb
alchemy_cms-7.2.4 lib/alchemy/name_conversions.rb
alchemy_cms-7.1.11 lib/alchemy/name_conversions.rb
alchemy_cms-7.2.3 lib/alchemy/name_conversions.rb
alchemy_cms-7.1.10 lib/alchemy/name_conversions.rb
alchemy_cms-7.2.2 lib/alchemy/name_conversions.rb
alchemy_cms-7.1.9 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.14 lib/alchemy/name_conversions.rb
alchemy_cms-7.2.1 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.13 lib/alchemy/name_conversions.rb
alchemy_cms-7.1.8 lib/alchemy/name_conversions.rb