Class: Addressable::URI

Inherits:
Object
  • Object
show all
Defined in:
lib/newsfetcher/extensions/addressable-uri.rb

Instance Method Summary collapse

Instance Method Details

#make_subscription_idObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/newsfetcher/extensions/addressable-uri.rb', line 5

def make_subscription_id
  [
    host.to_s \
      .sub(/^(www|ssl|en|feeds|rss|blogs?|news).*?\./i, '') \
      .sub(/\.(com|org|net|info|edu|co\.uk|wordpress\.com|blogspot\.com|feedburner\.com)$/i, ''),
    path.to_s \
      .gsub(/\b(\.?feeds?|index|atom|rss|rss2|xml|rdf|php|blog|posts|default)\b/i, ''),
    query.to_s \
      .gsub(/\b(format|feed|type|q)=(atom|rss\.xml|rss2?|xml)/i, ''),
  ] \
    .join(' ')
    .downcase
    .gsub(/[^a-z0-9]+/, ' ')  # non-alphanumeric
    .strip
    .gsub(/\s+/, '-')
end