Class: Despamilator
- Inherits:
-
Object
- Object
- Despamilator
- Defined in:
- lib/despamilator.rb,
lib/despamilator/filter.rb,
lib/despamilator/subject.rb,
lib/despamilator/version.rb,
lib/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
Constant Summary collapse
- VERSION =
'2.1.4'
Class Method Summary collapse
-
.gtubs_test_string ⇒ Object
Generic Test for Unsolicited Bulk Submissions.
Instance Method Summary collapse
-
#initialize(text) ⇒ Despamilator
constructor
Constructor.
- #matched_by ⇒ Object
-
#matches ⇒ Object
Returns an array of scores and filters that have matched and contributed to the score.
-
#score ⇒ Object
Returns the total score as a Float.
Constructor Details
#initialize(text) ⇒ Despamilator
Constructor. Takes the text you which to parse and score.
25 26 27 28 |
# File 'lib/despamilator.rb', line 25 def initialize text @subject = Despamilator::Subject.new text run_filters @subject end |
Class Method Details
.gtubs_test_string ⇒ Object
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.
60 61 62 |
# File 'lib/despamilator.rb', line 60 def self.gtubs_test_string '89913b8a065b7092721fe995877e097681683af9d3ab767146d5d6fd050fc0bda7ab99f4232d94a1' end |
Instance Method Details
#matched_by ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/despamilator.rb', line 36 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 |
#matches ⇒ Object
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.
53 54 55 |
# File 'lib/despamilator.rb', line 53 def matches @subject.matches end |
#score ⇒ Object
Returns the total score as a Float.
32 33 34 |
# File 'lib/despamilator.rb', line 32 def score @subject.score end |