death_by_captcha 0.4.1.0 → 0.4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/death_by_captcha/recaptcha.rb +15 -5
- data/lib/death_by_captcha/version.rb +1 -1
- metadata +3 -3
@@ -4,12 +4,20 @@ module DeathByCaptcha
|
|
4
4
|
|
5
5
|
Response = Struct.new( :code, :challenge )
|
6
6
|
|
7
|
+
@@default_options = { report: true }
|
8
|
+
|
9
|
+
def self.default_options
|
10
|
+
@@default_options
|
11
|
+
end
|
12
|
+
|
7
13
|
def initialize( site_id )
|
8
14
|
@site_id = site_id
|
9
15
|
end
|
10
|
-
|
11
|
-
def resolve
|
16
|
+
|
17
|
+
def resolve( opts = {} )
|
18
|
+
options = @@default_options.merge( opts )
|
12
19
|
response = nil
|
20
|
+
|
13
21
|
begin
|
14
22
|
request = Net::HTTP::Get.new( "/recaptcha/api/challenge?k=#{@site_id}" )
|
15
23
|
result = send_request( request )
|
@@ -24,14 +32,16 @@ module DeathByCaptcha
|
|
24
32
|
captcha_status = DeathByCaptcha.decode!( data )
|
25
33
|
code = captcha_status["text"]
|
26
34
|
rescue CaptchaInvalid
|
27
|
-
DeathByCaptcha.report( captcha_status["captcha"] )
|
35
|
+
DeathByCaptcha.report( captcha_status["captcha"] ) if options[:report] == true
|
28
36
|
raise CaptchaInvalid
|
29
37
|
end
|
30
38
|
|
31
39
|
return Response.new( captcha_status["text"], recaptcha_challenge_field )
|
32
40
|
end
|
33
41
|
|
34
|
-
def resolve_with_certification
|
42
|
+
def resolve_with_certification( opts = {} )
|
43
|
+
options = @@default_options.merge( opts )
|
44
|
+
|
35
45
|
begin
|
36
46
|
request = Net::HTTP::Get.new( "/recaptcha/api/noscript?k=#{@site_id}" )
|
37
47
|
result = send_request( request )
|
@@ -69,7 +79,7 @@ module DeathByCaptcha
|
|
69
79
|
|
70
80
|
raise CaptchaInvalid if textarea_node.nil?
|
71
81
|
rescue CaptchaInvalid
|
72
|
-
DeathByCaptcha.report( captcha_status["captcha"] )
|
82
|
+
DeathByCaptcha.report( captcha_status["captcha"] ) if options[:report] == truez
|
73
83
|
raise CaptchaInvalid
|
74
84
|
end
|
75
85
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: death_by_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project: death_by_captcha
|
66
|
-
rubygems_version: 1.8.
|
66
|
+
rubygems_version: 1.8.24
|
67
67
|
signing_key:
|
68
68
|
specification_version: 3
|
69
69
|
summary: Death by Captcha Ruby API
|