Class: Akismetor

Inherits:
Object show all
Defined in:
lib/aerial/vendor/akismetor.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Akismetor

Returns a new instance of Akismetor.



28
29
30
# File 'lib/aerial/vendor/akismetor.rb', line 28

def initialize(attributes)
  @attributes = attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



7
8
9
# File 'lib/aerial/vendor/akismetor.rb', line 7

def attributes
  @attributes
end

Class Method Details

.spam?(attributes) ⇒ Boolean

Does a comment-check on Akismet with the submitted hash. Returns true or false depending on response.

Returns:

  • (Boolean)


11
12
13
# File 'lib/aerial/vendor/akismetor.rb', line 11

def self.spam?(attributes)
  self.new(attributes).execute('comment-check') == "true"
end

.submit_ham(attributes) ⇒ Object

Does a submit-ham on Akismet with the submitted hash. Use this for a false positive, when Akismet incorrectly rejects a normal comment



23
24
25
# File 'lib/aerial/vendor/akismetor.rb', line 23

def self.submit_ham(attributes)
  self.new(attributes).execute('submit-ham')
end

.submit_spam(attributes) ⇒ Object

Does a submit-spam on Akismet with the submitted hash. Use this when Akismet incorrectly approves a spam comment.



17
18
19
# File 'lib/aerial/vendor/akismetor.rb', line 17

def self.submit_spam(attributes)
  self.new(attributes).execute('submit-spam')
end

Instance Method Details

#execute(command) ⇒ Object



32
33
34
35
36
# File 'lib/aerial/vendor/akismetor.rb', line 32

def execute(command)
  http = Net::HTTP.new("#{attributes[:key]}.rest.akismet.com", 80)
  response, content = http.post("/1.1/#{command}", attributes_for_post, http_headers)
  content
end