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.0.3 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.2 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.1 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.0 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.0.pre.rc1 lib/alchemy/name_conversions.rb
alchemy_cms-7.0.0.pre.c lib/alchemy/name_conversions.rb
alchemy_cms-7.0.0.pre.b lib/alchemy/name_conversions.rb