Sha256: a2dcc2bacfe6b136b965cc762ed5dcdb55856266c6f4d396d8bd900c33a55ad0
Contents?: true
Size: 768 Bytes
Versions: 13
Compression:
Stored size: 768 Bytes
Contents
# frozen_string_literal: true module OembedProxy # A couple of things pulled in from ActiveSupport, but using refinements # instead of monkeypatching. module InactiveSupport refine String do def parameterize(sep = '-') parameterized_string = dup.downcase # Turn unwanted chars into the separator parameterized_string.gsub!(/[^a-z0-9\-_]+/, sep) unless sep.nil? || sep.empty? re_sep = Regexp.escape(sep) # No more than one of the separator in a row. parameterized_string.gsub!(/#{re_sep}{2,}/, sep) # Remove leading/trailing separator. parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/, '') end parameterized_string.downcase end end end end
Version data entries
13 entries across 13 versions & 1 rubygems