Sha256: ddb8d9fb013c1595a97f0a114db3fb3cdc7c41901d7d406cdbb537920ecdc196

Contents?: true

Size: 803 Bytes

Versions: 4

Compression:

Stored size: 803 Bytes

Contents

# frozen_string_literal: true

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

4 entries across 4 versions & 1 rubygems

Version Path
geo_combine-0.9.2 lib/geo_combine/formatting.rb
geo_combine-0.9.1 lib/geo_combine/formatting.rb
geo_combine-0.9.0 lib/geo_combine/formatting.rb
geo_combine-0.8.0 lib/geo_combine/formatting.rb