Class: Viking::Akismet
Class Attribute Summary collapse
-
.host ⇒ Object
Returns the value of attribute host.
-
.normal_responses ⇒ Object
Returns the value of attribute normal_responses.
-
.port ⇒ Object
Returns the value of attribute port.
-
.standard_headers ⇒ Object
Returns the value of attribute standard_headers.
-
.valid_responses ⇒ Object
Returns the value of attribute valid_responses.
Attributes inherited from Base
Class Method Summary collapse
-
.url(action) ⇒ Object
Returns the URL for an Akismet request.
Instance Method Summary collapse
-
#check_comment(options = {}) ⇒ Object
This is basically the core of everything.
-
#initialize(options) ⇒ Akismet
constructor
Create a new instance of the Akismet class.
-
#mark_as_ham(options = {}) ⇒ Object
This call is intended for the marking of false positives, things that were incorrectly marked as spam.
-
#mark_as_spam(options = {}) ⇒ Object
This call is for submitting comments that weren’t marked as spam but should have been (i.e. false negatives).
-
#verified? ⇒ Boolean
Returns
true
if the API key has been verified,false
otherwise.
Methods inherited from Base
#check_article, #invalid_options?, logger, #logger, #mark_as_spam_or_ham, #stats
Constructor Details
#initialize(options) ⇒ Akismet
Create a new instance of the Akismet class
Arguments
Arguments are provided in the form of a Hash with the following keys (as Symbols) available:
api_key
-
your Akismet API key
blog
-
the blog associated with your api key
The following keys are available and are entirely optional. They are available incase communication with Akismet’s servers requires a proxy port and/or host:
-
proxy_port
-
proxy_host
49 50 51 52 |
# File 'lib/viking/akismet.rb', line 49 def initialize() super self.verified_key = false end |
Class Attribute Details
.host ⇒ Object
Returns the value of attribute host.
20 21 22 |
# File 'lib/viking/akismet.rb', line 20 def host @host end |
.normal_responses ⇒ Object
Returns the value of attribute normal_responses.
18 19 20 |
# File 'lib/viking/akismet.rb', line 18 def normal_responses @normal_responses end |
.port ⇒ Object
Returns the value of attribute port.
21 22 23 |
# File 'lib/viking/akismet.rb', line 21 def port @port end |
.standard_headers ⇒ Object
Returns the value of attribute standard_headers.
19 20 21 |
# File 'lib/viking/akismet.rb', line 19 def standard_headers @standard_headers end |
.valid_responses ⇒ Object
Returns the value of attribute valid_responses.
17 18 19 |
# File 'lib/viking/akismet.rb', line 17 def valid_responses @valid_responses end |
Class Method Details
.url(action) ⇒ Object
Returns the URL for an Akismet request
Arguments
action
<~to_s>-
a valid Akismet function name
Returns
String
124 125 126 |
# File 'lib/viking/akismet.rb', line 124 def self.url(action) "/1.1/#{action}" end |
Instance Method Details
#check_comment(options = {}) ⇒ Object
This is basically the core of everything. This call takes a number of arguments and characteristics about the submitted content and then returns a thumbs up or thumbs down. Almost everything is optional, but performance can drop dramatically if you exclude certain elements.
Arguments
options
<Hash>-
describes the comment being verified
The following keys are available for the options
hash:
user_ip
(required)-
IP address of the comment submitter.
user_agent
(required)-
user agent information.
referrer
(note spelling)-
the content of the HTTP_REFERER header should be sent here.
permalink
-
permanent location of the entry the comment was submitted to
comment_type
-
may be blank, comment, trackback, pingback, or a made up value like “registration”.
comment_author
-
submitted name with the comment
comment_author_email
-
submitted email address
comment_author_url
-
commenter URL
comment_content
-
the content that was submitted
- Other server enviroment variables
-
In PHP there is an array of enviroment variables called
_SERVER
which contains information about the web server itself as well as a key/value for every HTTP header sent with the request. This data is highly useful to Akismet as how the submited content interacts with the server can be very telling, so please include as much information as possible.
95 96 97 98 99 |
# File 'lib/viking/akismet.rb', line 95 def check_comment( = {}) return false if = ('comment-check', ) { :spam => !self.class.valid_responses.include?(), :message => } end |
#mark_as_ham(options = {}) ⇒ Object
This call is intended for the marking of false positives, things that were incorrectly marked as spam. It takes identical arguments as check_comment
and mark_as_spam
.
112 113 114 115 |
# File 'lib/viking/akismet.rb', line 112 def mark_as_ham( = {}) return false if { :message => ('submit-ham', ) } end |
#mark_as_spam(options = {}) ⇒ Object
This call is for submitting comments that weren’t marked as spam but should have been (i.e. false negatives). It takes identical arguments as check_comment
.
104 105 106 107 |
# File 'lib/viking/akismet.rb', line 104 def mark_as_spam( = {}) return false if { :message => ('submit-spam', ) } end |
#verified? ⇒ Boolean
Returns true
if the API key has been verified, false
otherwise
55 56 57 |
# File 'lib/viking/akismet.rb', line 55 def verified? (@verified_key ||= verify_api_key) != :false end |