Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass blog url as a param #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/rakismet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def validate_key
validate_config
akismet = URI.parse(verify_url)
response = Net::HTTP.start(akismet.host, use_ssl: true, p_addr: proxy_host, p_port: proxy_port) do |http|
data = "key=#{Rakismet.key}&blog=#{Rakismet.url}"
data = "key=#{Rakismet.key}"
http.post(akismet.path, data, Rakismet.headers)
end
@valid_key = (response.body == 'valid')
Expand All @@ -67,7 +67,7 @@ def valid_key?

def akismet_call(function, args={})
validate_config
args.merge!(:blog => Rakismet.url, :is_test => Rakismet.test_mode)
args.merge!(:is_test => Rakismet.test_mode)
akismet = URI.parse(call_url(function))
response = Net::HTTP.start(akismet.host, use_ssl: true, p_addr: proxy_host, p_port: proxy_port) do |http|
params = args.map do |k,v|
Expand All @@ -91,7 +91,6 @@ def call_url(function)

def validate_config
raise Undefined, "Rakismet.key is not defined" if Rakismet.key.nil? || Rakismet.key.empty?
raise Undefined, "Rakismet.url is not defined" if Rakismet.url.nil? || Rakismet.url.empty?
raise Undefined, "Rakismet.host is not defined" if Rakismet.host.nil? || Rakismet.host.empty?
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rakismet/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def rakismet_attrs(args={})
fieldname = "comment_#{field}".intern
self.akismet_attrs[fieldname] = args.delete(field) || field
end
[:comment_type, :user_ip, :user_agent, :referrer, :user_role, :permalink].each do |field|
[:comment_type, :user_ip, :user_agent, :referrer, :user_role, :permalink, :blog].each do |field|
self.akismet_attrs[field] = args.delete(field) || field
end
args.each_pair do |f,v|
Expand Down Expand Up @@ -65,7 +65,7 @@ def akismet_data(include_http_headers = false)
elsif not [:comment_type, :author, :author_email,
:author_url, :content, :user_role, :permalink,
:user_ip, :referrer,
:user_agent].include?(mapped_field)
:user_agent, :blog].include?(mapped_field)
# we've excluded any fields that appear to
# have their default unmapped values
mapped_field
Expand Down
1 change: 0 additions & 1 deletion lib/rakismet/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Railtie < Rails::Railtie

initializer 'rakismet.setup', :after => :load_config_initializers do |app|
Rakismet.key = app.config.rakismet[:key]
Rakismet.url = app.config.rakismet[:url]
Rakismet.host = app.config.rakismet[:host]
Rakismet.proxy_host = app.config.rakismet[:proxy_host]
Rakismet.proxy_port = app.config.rakismet[:proxy_port]
Expand Down
5 changes: 0 additions & 5 deletions spec/rakismet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ def mock_response(body)
lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined)
end

it "should raise an error if url is not found" do
Rakismet.url = ''
lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined)
end

it "should raise an error if host is not found" do
Rakismet.host = ''
lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined)
Expand Down