Class: Gluttonberg::Content::Despamilator

Inherits:
Object
  • Object
show all
Defined in:
lib/gluttonberg/content/despamilator.rb,
lib/gluttonberg/content/despamilator/filter.rb,
lib/gluttonberg/content/despamilator/subject.rb,
lib/gluttonberg/content/despamilator/version.rb,
lib/gluttonberg/content/despamilator/subject/text.rb

Overview

SYNOPSIS:

require 'despamilator'

# some time later...

dspam = Despamilator.new('some text with an <h2> tag qthhg')

dspam.score #=> the total score for this string (1 is normally my threshold).
dspam.matches #=> array of hashes containing matching filters and their score.

Defined Under Namespace

Classes: Filter, Subject

Constant Summary collapse

VERSION =
'2.1.4'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Despamilator

Constructor. Takes the text you which to parse and score.



27
28
29
30
# File 'lib/gluttonberg/content/despamilator.rb', line 27

def initialize text
  @subject = Despamilator::Subject.new text
  run_filters @subject
end

Class Method Details

.gtubs_test_stringObject

Generic Test for Unsolicited Bulk Submissions. Similar to SpamAssassin’s GTUBE. A string that will result in a spam score of at least 100. Handy for testing.



62
63
64
# File 'lib/gluttonberg/content/despamilator.rb', line 62

def self.gtubs_test_string
  '89913b8a065b7092721fe995877e097681683af9d3ab767146d5d6fd050fc0bda7ab99f4232d94a1'
end

Instance Method Details

#matched_byObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gluttonberg/content/despamilator.rb', line 38

def matched_by
  warn 'Despamilator.matched_by is deprecated, please use Despamilator.matches by 2011-12-31.'

  matches.map do |match|
    filter = match[:filter]

    OpenStruct.new(
        :name => filter.name,
        :description => filter.description,
        :score => match[:score]
    )
  end
end

#matchesObject

Returns an array of scores and filters that have matched and contributed to the score. Each element is a a child of the Despamilator::FilterBase class.



55
56
57
# File 'lib/gluttonberg/content/despamilator.rb', line 55

def matches
  @subject.matches
end

#scoreObject

Returns the total score as a Float.



34
35
36
# File 'lib/gluttonberg/content/despamilator.rb', line 34

def score
  @subject.score
end