Sha256: b488942492c1bdb951730550f80914021529e0784d1b1d7f4103c1a1a11e08df

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

module GeoCombine
  ##
  # Mixin used for formatting metadata fields
  module Formatting
    ##
    # Sanitizes html from a text input
    # @param [String] text
    # @return [String]
    def sanitize(text)
      Sanitize.fragment(text)
    end

    ##
    # Removes line breaks from a text input
    # @param [String] text
    # @return [String]
    def remove_lines(text)
      text.delete("\n")
    end

    ##
    # Sanitizes and removes lines from a text block
    # @param [String] text
    # @return [String]
    def sanitize_and_remove_lines(text)
      remove_lines(sanitize(text))
    end

    # slugs should be lowercase and only have a-z, A-Z, 0-9, and -
    def sluggify(slug)
      slug.gsub(/[^a-zA-Z0-9\-]/, '-').gsub(/[\-]+/, '-').downcase
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
geo_combine-0.5.1 lib/geo_combine/formatting.rb
geo_combine-0.5.0 lib/geo_combine/formatting.rb
geo_combine-0.4.0 lib/geo_combine/formatting.rb