Sha256: 1a0bec42834732ada4bea2fd75c7a284ddb70ad3994218cb6e0c29e1a367b770
Contents?: true
Size: 773 Bytes
Versions: 1
Compression:
Stored size: 773 Bytes
Contents
module Asana2Flowdock class Slug < ::String Join = '-' def Slug.for(*args) options = args.last.is_a?(Hash) ? args.pop : {} join = (options[:join]||options['join']||Join).to_s string = args.flatten.compact.join(join) string = unidecode(string) words = string.to_s.scan(%r|[/\w]+|) words.map!{|word| word.gsub %r|[_-]|, join} words.map!{|word| word.gsub %r|[^/0-9a-zA-Z_-]|, ''} words.delete_if{|word| word.nil? or word.strip.empty?} new(words.join(join).downcase.gsub('/', (join * 2))) end unless defined?(Stringex::Unidecoder) def Slug.unidecode(string) string end else def Slug.unidecode(string) Stringex::Unidecoder.decode(string) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asana2flowdock-1.3.0 | lib/asana2flowdock/slug.rb |