recaptcha 3.0.0 → 3.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8bf11b481c77b41f01408a1a79f001e1bd7752d
4
- data.tar.gz: ca7ae6470f682b80d318a919d1b52559c801c593
3
+ metadata.gz: ca2ec26c375c95c1459db34eda553e75cbfaa1b1
4
+ data.tar.gz: 85136cf39a2bcc76269935fde5265a60162d3a80
5
5
  SHA512:
6
- metadata.gz: f65791a9b97640e4d3080b36f25b5f8c933d18162a5ba711f0379f24c22bd916c3d058d7d00918866bb50c80d9fa1c0e686f3305545b34d39736a77927b2a067
7
- data.tar.gz: ad562b54afb143099f856fb08d13a46cdf3aa543b3adcdf2455e8c9451427c57a68533dd4f4455aaa7319ee41d3e42751738f5b9e740c7a92593b90696589cb5
6
+ metadata.gz: 7280548570fb6c61c15e18f6ad6f533b06b1df491e7b31f26ad5fcf99b40ff9a5e737dfbf70106b5e96ffd8cd457809459092d693a0450730fbf3a6dae4b5f17
7
+ data.tar.gz: b002273c513e292f91d5febca4bc37264ddd0495f3b38b7e90781cc647d1a7eda5471a8123b4d479da7845b5d5df6600864560493fd1d72832d23490d1f70c18
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.0.0 - 2016-05-27
2
+ * remove all non-ssl options
3
+
1
4
  ## 2.3.0 - 2016-05-25
2
5
  * enable ssl verification by default ... disable via `disable_ssl_verification = true`
3
6
 
data/lib/recaptcha.rb CHANGED
@@ -8,11 +8,11 @@ module Recaptcha
8
8
  CONFIG = {
9
9
  'server_url' => 'https://www.google.com/recaptcha/api.js',
10
10
  'verify_url' => 'https://www.google.com/recaptcha/api/siteverify'
11
- }
11
+ }.freeze
12
12
 
13
13
  USE_SSL_BY_DEFAULT = false
14
14
  HANDLE_TIMEOUTS_GRACEFULLY = true
15
- SKIP_VERIFY_ENV = ['test', 'cucumber']
15
+ SKIP_VERIFY_ENV = ['test', 'cucumber'].freeze
16
16
  DEFAULT_TIMEOUT = 3
17
17
 
18
18
  # Gives access to the current Configuration.
@@ -68,7 +68,6 @@ module Recaptcha
68
68
  end
69
69
  end
70
70
 
71
-
72
71
  class RecaptchaError < StandardError
73
72
  end
74
73
 
@@ -3,8 +3,13 @@ module Recaptcha
3
3
  # Your public API can be specified in the +options+ hash or preferably
4
4
  # using the Configuration.
5
5
  def recaptcha_tags(options = {})
6
- raise(RecaptchaError, "Secure Token is deprecated.") if options.key?(:stoken)
7
- raise(RecaptchaError, "SSL is always true.") if options.key?(:ssl)
6
+ if options.key?(:stoken)
7
+ raise(RecaptchaError, "Secure Token is deprecated. Please remove 'stoken' from your calls to recaptcha_tags.")
8
+ end
9
+ if options.key?(:ssl)
10
+ raise(RecaptchaError, "SSL is now always true. Please remove 'ssl' from your calls to recaptcha_tags.")
11
+ end
12
+
8
13
  public_key = options[:public_key] || Recaptcha.configuration.public_key!
9
14
 
10
15
  script_url = Recaptcha.configuration.api_server_url
@@ -16,10 +21,10 @@ module Recaptcha
16
21
  a[k] = v if data_attributes.include?(k)
17
22
  end
18
23
  data_attributes[:sitekey] = public_key
19
- data_attributes = data_attributes.map { |k,v| %{data-#{k.to_s.tr('_','-')}="#{v}"} }.join(" ")
24
+ data_attributes = data_attributes.map { |k, v| %(data-#{k.to_s.tr('_', '-')}="#{v}") }.join(" ")
20
25
 
21
- html = %{<script src="#{script_url}" async defer></script>\n}
22
- html << %{<div class="g-recaptcha" #{data_attributes}></div>\n}
26
+ html = %(<script src="#{script_url}" async defer></script>\n)
27
+ html << %(<div class="g-recaptcha" #{data_attributes}></div>\n)
23
28
 
24
29
  if options[:noscript] != false
25
30
  html << <<-HTML
@@ -5,7 +5,7 @@ module Recaptcha
5
5
  # Your private API can be specified in the +options+ hash or preferably
6
6
  # using the Configuration.
7
7
  def verify_recaptcha(options = {})
8
- options = {:model => options} unless options.is_a? Hash
8
+ options = {model: options} unless options.is_a? Hash
9
9
  return true if Recaptcha::Verify.skip?(options[:env])
10
10
 
11
11
  model = options[:model]
@@ -51,7 +51,12 @@ module Recaptcha
51
51
  end
52
52
 
53
53
  def verify_recaptcha!(options = {})
54
- verify_recaptcha(options) or raise VerifyError
54
+ verify_recaptcha(options) || raise(VerifyError)
55
+ end
56
+
57
+ def self.skip?(env)
58
+ env ||= ENV['RACK_ENV'] || ENV['RAILS_ENV'] || (Rails.env if defined? Rails.env)
59
+ Recaptcha.configuration.skip_verify_env.include? env
55
60
  end
56
61
 
57
62
  private
@@ -82,7 +87,7 @@ module Recaptcha
82
87
  end
83
88
 
84
89
  def recaptcha_error(model, attribute, message, key, default)
85
- message = message || Recaptcha.i18n(key, default)
90
+ message ||= Recaptcha.i18n(key, default)
86
91
  if model
87
92
  model.errors.add attribute, message
88
93
  else
@@ -93,10 +98,5 @@ module Recaptcha
93
98
  def recaptcha_flash_supported?
94
99
  request.respond_to?(:format) && request.format == :html && respond_to?(:flash)
95
100
  end
96
-
97
- def self.skip?(env)
98
- env ||= ENV['RACK_ENV'] || ENV['RAILS_ENV'] || (Rails.env if defined? Rails.env)
99
- Recaptcha.configuration.skip_verify_env.include? env
100
- end
101
101
  end
102
102
  end
@@ -1,3 +1,3 @@
1
1
  module Recaptcha
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason L Perry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-28 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Helpers for the reCAPTCHA API
140
154
  email:
141
155
  - jasper@ambethia.com