Class: Gluttonberg::Content::DespamilatorFilter::VeryLongDomainName

Inherits:
Gluttonberg::Content::Despamilator::Filter show all
Defined in:
lib/gluttonberg/content/despamilator/filter/very_long_domain_name.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



14
15
16
# File 'lib/gluttonberg/content/despamilator/filter/very_long_domain_name.rb', line 14

def description
  'Detects unusually long domain names.'
end

#nameObject



10
11
12
# File 'lib/gluttonberg/content/despamilator/filter/very_long_domain_name.rb', line 10

def name
  'Very Long Domain Name'
end

#parse(subject) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/gluttonberg/content/despamilator/filter/very_long_domain_name.rb', line 18

def parse subject
  subject.text.scan(URI.regexp).each do |url_parts|
    url_parts.compact!
    next if !url_parts[1] or url_parts[1] !~ /(\w|-){5,}\.\w{2,5}/
    url = Domainatrix.parse('http://' + url_parts[1])
    subject.register_match!({:score => 0.4, :filter => self}) if url.domain.length > 20
  end
end