Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Commit

Permalink
1.9-style hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
kirs committed Apr 12, 2013
1 parent f0d4393 commit f244a29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions lib/yandex_cleanweb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def spam?(*options)
[el.attributes["url"], el.attributes["spam_flag"] == 'yes']
end

{ :id => request_id, :links => links }
{ id: request_id, links: links }
else
false
end
Expand All @@ -42,7 +42,7 @@ def get_captcha(request_id)
url = doc.xpath('//get-captcha-result/url').text
captcha_id = doc.xpath('//get-captcha-result/captcha').text

{ :url => url, :captcha => captcha_id }
{ url: url, captcha: captcha_id }
end

def valid_captcha?(request_id, captcha_id, value)
Expand All @@ -56,10 +56,10 @@ def valid_captcha?(request_id, captcha_id, value)
def api_check_captcha(request_id, captcha_id, value)
check_captcha_url = "#{API_URL}/check-captcha"
params = {
:key => prepare_api_key,
:id => request_id,
:captcha => captcha_id,
:value => value
key: prepare_api_key,
id: request_id,
captcha: captcha_id,
value: value
}

uri = URI.parse(check_captcha_url)
Expand All @@ -70,7 +70,7 @@ def api_check_captcha(request_id, captcha_id, value)

def api_get_captcha(request_id)
get_captcha_url = "#{API_URL}/get-captcha"
params = { :key => prepare_api_key, :id => request_id }
params = { key: prepare_api_key, id: request_id }

uri = URI.parse(get_captcha_url)
uri.query = URI.encode_www_form(params)
Expand All @@ -79,7 +79,7 @@ def api_get_captcha(request_id)
end

def api_check_spam(options)
cleanweb_options = { :key => prepare_api_key }
cleanweb_options = { key: prepare_api_key }

if options[0].is_a?(String) # quick check
cleanweb_options[:body_plain] = options[0]
Expand Down
6 changes: 3 additions & 3 deletions test/yandex_cleanweb_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@

describe "advanced mode" do
it "works" do
YandexCleanweb.spam?(:body_plain => "my text", :ip => "80.80.40.3").must_equal false
YandexCleanweb.spam?(body_plain: "my text", ip: "80.80.40.3").must_equal false
end

it "with some html" do
result = YandexCleanweb.spam?(:body_html => "some spam <a href='http://spam.com'>spam link</a>")
result = YandexCleanweb.spam?(body_html: "some spam <a href='http://spam.com'>spam link</a>")

result[:id].wont_be_empty
result[:links].must_be_empty
Expand All @@ -78,7 +78,7 @@
describe "#get_captcha + #valid_captcha?" do

it "works for not valid captchas" do
result = YandexCleanweb.spam?(:body_html => "some spam <a href='http://spam.com'>spam link</a>")
result = YandexCleanweb.spam?(body_html: "some spam <a href='http://spam.com'>spam link</a>")
captcha = YandexCleanweb.get_captcha(result[:id])

captcha[:url].wont_be_empty
Expand Down

0 comments on commit f244a29

Please sign in to comment.