antage-merb-recaptcha 1.0.2 → 1.0.3

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/Rakefile CHANGED
@@ -3,17 +3,13 @@ require 'rake/gempackagetask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rake/clean'
5
5
 
6
- require 'yard'
7
- require 'yard/rake/yardoc_task'
8
-
9
6
  require 'spec/rake/spectask'
10
7
 
11
8
  require 'merb-core'
12
9
  require 'merb-core/tasks/merb'
13
10
 
14
11
  GEM_NAME = "merb-recaptcha"
15
- GEM_VERSION = "1.0.2"
16
- AUTHOR = "Anton Ageev"
12
+ GEM_VERSION = "1.0.3"
17
13
  EMAIL = "antage@gmail.com"
18
14
  HOMEPAGE = "http://github.com/antage/merb-recaptcha/"
19
15
  SUMMARY = "Merb plugin that provides helpers for recaptcha.net service"
@@ -23,12 +19,12 @@ spec = Gem::Specification.new do |s|
23
19
  s.name = GEM_NAME
24
20
  s.version = GEM_VERSION
25
21
  s.platform = Gem::Platform::RUBY
22
+ s.authors = ["Anton Ageev", "Michael Johnston"]
26
23
  s.has_rdoc = true
27
24
  s.extra_rdoc_files = [ "README.rdoc", "LICENSE" ]
28
25
  s.rdoc_options << "--main" << "README.rdoc"
29
26
  s.summary = SUMMARY
30
27
  s.description = s.summary
31
- s.author = AUTHOR
32
28
  s.email = EMAIL
33
29
  s.homepage = HOMEPAGE
34
30
  s.require_path = 'lib'
@@ -10,16 +10,26 @@ module Merb # :nodoc:
10
10
  #
11
11
  def recaptcha_valid?
12
12
  return true if (Merb.testing? && !Merb::RecaptchaMixin.const_defined?(:DO_NOT_IGNORE_RECAPTCHA_IN_TESTING_ENV))
13
- response = Net::HTTP.post_form(URI.parse("#{Merb::Recaptcha::API_VERIFY_SERVER}/verify"), {
14
- :privatekey => Merb::Plugins.config[:merb_recaptcha][:private_key],
15
- :remoteip => request.remote_ip,
16
- :challenge => params[:recaptcha_challenge_field],
17
- :response => params[:recaptcha_response_field]
18
- })
13
+ begin
14
+ response = Net::HTTP.post_form(URI.parse("#{Merb::Recaptcha::API_VERIFY_SERVER}/verify"), {
15
+ :privatekey => Merb::Plugins.config[:merb_recaptcha][:private_key],
16
+ :remoteip => request.remote_ip,
17
+ :challenge => params[:recaptcha_challenge_field],
18
+ :response => params[:recaptcha_response_field]
19
+ })
20
+ rescue Exception => e
21
+ if Merb.env?(:production) || ENV['OFFLINE']
22
+ Merb.logger.error("when trying to connect to recaptcha, got #{e.message}")
23
+ return true;
24
+ else
25
+ raise
26
+ end
27
+ end
19
28
  answer, error = response.body.split.map { |s| s.chomp }
20
29
  if answer == "true"
21
30
  true
22
31
  else
32
+ Merb.logger.fatal("recaptcha error: #{error} for #{request.remote_ip}")
23
33
  case error
24
34
  when "incorrect-captcha-sol" then false
25
35
  when "invalid-site-public-key" then raise Merb::Recaptcha::InvalidSitePublicKey
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{merb-recaptcha}
5
- s.version = "1.0.2"
5
+ s.version = "1.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Anton Ageev"]
9
- s.date = %q{2008-12-19}
8
+ s.authors = ["Anton Ageev", "Michael Johnston"]
9
+ s.date = %q{2009-05-29}
10
10
  s.description = %q{Merb plugin that provides helpers for recaptcha.net service}
11
11
  s.email = %q{antage@gmail.com}
12
12
  s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
13
- s.files = ["LICENSE", "README.rdoc", "Rakefile", "TODO", "merb-recaptcha.gemspec", "lib/merb-recaptcha/constants.rb", "lib/merb-recaptcha/merbtasks.rb", "lib/merb-recaptcha/controller_mixin.rb", "lib/merb-recaptcha/view_helpers.rb", "lib/merb-recaptcha/exceptions.rb", "lib/merb-recaptcha.rb", "spec/spec_helper.rb", "spec/recaptcha_ajax_with_options_spec.rb", "spec/recaptcha_noajax_without_noscript_spec.rb", "spec/recaptcha_noajax_with_noscript_spec.rb", "spec/recaptcha_valid_spec.rb", "spec/recaptcha_ajax_spec.rb", "spec/recaptcha_ajax_with_callback_spec.rb", "spec/recaptcha_noajax_with_options_spec.rb", "spec/recaptcha_ajax_with_jquery_spec.rb", "spec/fixture/app/controllers/application.rb", "spec/fixture/app/controllers/exceptions.rb", "spec/fixture/app/controllers/recaptcha.rb", "spec/fixture/app/views/exceptions/not_acceptable.html.erb", "spec/fixture/app/views/exceptions/not_found.html.erb", "spec/fixture/app/views/layout/application.html.erb", "spec/fixture/app/views/recaptcha/ajax.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb", "spec/fixture/app/helpers/global_helpers.rb", "spec/fixture/app/helpers/recaptcha_helpers.rb"]
13
+ s.files = ["LICENSE", "README.rdoc", "Rakefile", "TODO", "merb-recaptcha.gemspec", "lib/merb-recaptcha/merbtasks.rb", "lib/merb-recaptcha/constants.rb", "lib/merb-recaptcha/exceptions.rb", "lib/merb-recaptcha/view_helpers.rb", "lib/merb-recaptcha/controller_mixin.rb", "lib/merb-recaptcha.rb", "spec/spec_helper.rb", "spec/recaptcha_ajax_with_callback_spec.rb", "spec/recaptcha_noajax_with_noscript_spec.rb", "spec/recaptcha_noajax_with_options_spec.rb", "spec/recaptcha_ajax_spec.rb", "spec/recaptcha_ajax_with_jquery_spec.rb", "spec/recaptcha_ajax_with_options_spec.rb", "spec/recaptcha_noajax_without_noscript_spec.rb", "spec/recaptcha_valid_spec.rb", "spec/fixture/app/views/layout/application.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_options.html.erb", "spec/fixture/app/views/exceptions/not_acceptable.html.erb", "spec/fixture/app/views/exceptions/not_found.html.erb", "spec/fixture/app/controllers/exceptions.rb", "spec/fixture/app/controllers/application.rb", "spec/fixture/app/controllers/recaptcha.rb", "spec/fixture/app/helpers/recaptcha_helpers.rb", "spec/fixture/app/helpers/global_helpers.rb"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/antage/merb-recaptcha/}
16
16
  s.rdoc_options = ["--main", "README.rdoc"]
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.rubyforge_project = %q{merb-recaptcha}
19
19
  s.rubygems_version = %q{1.3.1}
20
20
  s.summary = %q{Merb plugin that provides helpers for recaptcha.net service}
21
- s.test_files = ["spec/spec_helper.rb", "spec/recaptcha_ajax_with_options_spec.rb", "spec/recaptcha_noajax_without_noscript_spec.rb", "spec/recaptcha_noajax_with_noscript_spec.rb", "spec/recaptcha_valid_spec.rb", "spec/recaptcha_ajax_spec.rb", "spec/recaptcha_ajax_with_callback_spec.rb", "spec/recaptcha_noajax_with_options_spec.rb", "spec/recaptcha_ajax_with_jquery_spec.rb", "spec/fixture/app/controllers/application.rb", "spec/fixture/app/controllers/exceptions.rb", "spec/fixture/app/controllers/recaptcha.rb", "spec/fixture/app/views/exceptions/not_acceptable.html.erb", "spec/fixture/app/views/exceptions/not_found.html.erb", "spec/fixture/app/views/layout/application.html.erb", "spec/fixture/app/views/recaptcha/ajax.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb", "spec/fixture/app/helpers/global_helpers.rb", "spec/fixture/app/helpers/recaptcha_helpers.rb"]
21
+ s.test_files = ["spec/spec_helper.rb", "spec/recaptcha_ajax_with_callback_spec.rb", "spec/recaptcha_noajax_with_noscript_spec.rb", "spec/recaptcha_noajax_with_options_spec.rb", "spec/recaptcha_ajax_spec.rb", "spec/recaptcha_ajax_with_jquery_spec.rb", "spec/recaptcha_ajax_with_options_spec.rb", "spec/recaptcha_noajax_without_noscript_spec.rb", "spec/recaptcha_valid_spec.rb", "spec/fixture/app/views/layout/application.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_options.html.erb", "spec/fixture/app/views/exceptions/not_acceptable.html.erb", "spec/fixture/app/views/exceptions/not_found.html.erb", "spec/fixture/app/controllers/exceptions.rb", "spec/fixture/app/controllers/application.rb", "spec/fixture/app/controllers/recaptcha.rb", "spec/fixture/app/helpers/recaptcha_helpers.rb", "spec/fixture/app/helpers/global_helpers.rb"]
22
22
 
23
23
  if s.respond_to? :specification_version then
24
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -110,4 +110,16 @@ describe "FakeController#check_recaptcha" do
110
110
  lambda { do_request }.should raise_error(Merb::Recaptcha::InvalidReferrer)
111
111
  end
112
112
  end
113
+
114
+ describe "when can't connect to recaptcha" do
115
+ before(:each) do
116
+ Net::HTTP.stubs(:post_form).times(2).raises(Exception, "can't connect to recaptcha")
117
+ end
118
+
119
+ it "should pass through if env var OFFLINE is set" do
120
+ lambda { do_request }.should raise_error(Exception)
121
+ ENV['OFFLINE'] = '1'
122
+ lambda { do_request }.should_not raise_error
123
+ end
124
+ end
113
125
  end
metadata CHANGED
@@ -1,19 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: antage-merb-recaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Ageev
8
+ - Michael Johnston
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2008-12-19 00:00:00 -08:00
13
+ date: 2009-05-29 00:00:00 -07:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: merb-core
18
+ type: :runtime
17
19
  version_requirement:
18
20
  version_requirements: !ruby/object:Gem::Requirement
19
21
  requirements:
@@ -23,6 +25,7 @@ dependencies:
23
25
  version:
24
26
  - !ruby/object:Gem::Dependency
25
27
  name: builder
28
+ type: :runtime
26
29
  version_requirement:
27
30
  version_requirements: !ruby/object:Gem::Requirement
28
31
  requirements:
@@ -32,6 +35,7 @@ dependencies:
32
35
  version:
33
36
  - !ruby/object:Gem::Dependency
34
37
  name: rspec
38
+ type: :development
35
39
  version_requirement:
36
40
  version_requirements: !ruby/object:Gem::Requirement
37
41
  requirements:
@@ -41,6 +45,7 @@ dependencies:
41
45
  version:
42
46
  - !ruby/object:Gem::Dependency
43
47
  name: mocha
48
+ type: :development
44
49
  version_requirement:
45
50
  version_requirements: !ruby/object:Gem::Requirement
46
51
  requirements:
@@ -63,36 +68,36 @@ files:
63
68
  - Rakefile
64
69
  - TODO
65
70
  - merb-recaptcha.gemspec
66
- - lib/merb-recaptcha/constants.rb
67
71
  - lib/merb-recaptcha/merbtasks.rb
68
- - lib/merb-recaptcha/controller_mixin.rb
69
- - lib/merb-recaptcha/view_helpers.rb
72
+ - lib/merb-recaptcha/constants.rb
70
73
  - lib/merb-recaptcha/exceptions.rb
74
+ - lib/merb-recaptcha/view_helpers.rb
75
+ - lib/merb-recaptcha/controller_mixin.rb
71
76
  - lib/merb-recaptcha.rb
72
77
  - spec/spec_helper.rb
73
- - spec/recaptcha_ajax_with_options_spec.rb
74
- - spec/recaptcha_noajax_without_noscript_spec.rb
75
- - spec/recaptcha_noajax_with_noscript_spec.rb
76
- - spec/recaptcha_valid_spec.rb
77
- - spec/recaptcha_ajax_spec.rb
78
78
  - spec/recaptcha_ajax_with_callback_spec.rb
79
+ - spec/recaptcha_noajax_with_noscript_spec.rb
79
80
  - spec/recaptcha_noajax_with_options_spec.rb
81
+ - spec/recaptcha_ajax_spec.rb
80
82
  - spec/recaptcha_ajax_with_jquery_spec.rb
81
- - spec/fixture/app/controllers/application.rb
82
- - spec/fixture/app/controllers/exceptions.rb
83
- - spec/fixture/app/controllers/recaptcha.rb
84
- - spec/fixture/app/views/exceptions/not_acceptable.html.erb
85
- - spec/fixture/app/views/exceptions/not_found.html.erb
83
+ - spec/recaptcha_ajax_with_options_spec.rb
84
+ - spec/recaptcha_noajax_without_noscript_spec.rb
85
+ - spec/recaptcha_valid_spec.rb
86
86
  - spec/fixture/app/views/layout/application.html.erb
87
- - spec/fixture/app/views/recaptcha/ajax.html.erb
88
87
  - spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb
89
- - spec/fixture/app/views/recaptcha/ajax_with_options.html.erb
90
- - spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb
91
- - spec/fixture/app/views/recaptcha/noajax_with_options.html.erb
92
88
  - spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb
89
+ - spec/fixture/app/views/recaptcha/ajax.html.erb
93
90
  - spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb
94
- - spec/fixture/app/helpers/global_helpers.rb
91
+ - spec/fixture/app/views/recaptcha/noajax_with_options.html.erb
92
+ - spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb
93
+ - spec/fixture/app/views/recaptcha/ajax_with_options.html.erb
94
+ - spec/fixture/app/views/exceptions/not_acceptable.html.erb
95
+ - spec/fixture/app/views/exceptions/not_found.html.erb
96
+ - spec/fixture/app/controllers/exceptions.rb
97
+ - spec/fixture/app/controllers/application.rb
98
+ - spec/fixture/app/controllers/recaptcha.rb
95
99
  - spec/fixture/app/helpers/recaptcha_helpers.rb
100
+ - spec/fixture/app/helpers/global_helpers.rb
96
101
  has_rdoc: true
97
102
  homepage: http://github.com/antage/merb-recaptcha/
98
103
  post_install_message:
@@ -122,26 +127,26 @@ specification_version: 2
122
127
  summary: Merb plugin that provides helpers for recaptcha.net service
123
128
  test_files:
124
129
  - spec/spec_helper.rb
125
- - spec/recaptcha_ajax_with_options_spec.rb
126
- - spec/recaptcha_noajax_without_noscript_spec.rb
127
- - spec/recaptcha_noajax_with_noscript_spec.rb
128
- - spec/recaptcha_valid_spec.rb
129
- - spec/recaptcha_ajax_spec.rb
130
130
  - spec/recaptcha_ajax_with_callback_spec.rb
131
+ - spec/recaptcha_noajax_with_noscript_spec.rb
131
132
  - spec/recaptcha_noajax_with_options_spec.rb
133
+ - spec/recaptcha_ajax_spec.rb
132
134
  - spec/recaptcha_ajax_with_jquery_spec.rb
133
- - spec/fixture/app/controllers/application.rb
134
- - spec/fixture/app/controllers/exceptions.rb
135
- - spec/fixture/app/controllers/recaptcha.rb
136
- - spec/fixture/app/views/exceptions/not_acceptable.html.erb
137
- - spec/fixture/app/views/exceptions/not_found.html.erb
135
+ - spec/recaptcha_ajax_with_options_spec.rb
136
+ - spec/recaptcha_noajax_without_noscript_spec.rb
137
+ - spec/recaptcha_valid_spec.rb
138
138
  - spec/fixture/app/views/layout/application.html.erb
139
- - spec/fixture/app/views/recaptcha/ajax.html.erb
140
139
  - spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb
141
- - spec/fixture/app/views/recaptcha/ajax_with_options.html.erb
142
- - spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb
143
- - spec/fixture/app/views/recaptcha/noajax_with_options.html.erb
144
140
  - spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb
141
+ - spec/fixture/app/views/recaptcha/ajax.html.erb
145
142
  - spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb
146
- - spec/fixture/app/helpers/global_helpers.rb
143
+ - spec/fixture/app/views/recaptcha/noajax_with_options.html.erb
144
+ - spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb
145
+ - spec/fixture/app/views/recaptcha/ajax_with_options.html.erb
146
+ - spec/fixture/app/views/exceptions/not_acceptable.html.erb
147
+ - spec/fixture/app/views/exceptions/not_found.html.erb
148
+ - spec/fixture/app/controllers/exceptions.rb
149
+ - spec/fixture/app/controllers/application.rb
150
+ - spec/fixture/app/controllers/recaptcha.rb
147
151
  - spec/fixture/app/helpers/recaptcha_helpers.rb
152
+ - spec/fixture/app/helpers/global_helpers.rb