aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gems/recaptcha-0.3.1/lib/recaptcha/configuration.rb
blob: 210470a5bafc2ddfc1ee3179ae5a60d4f065b1c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module Recaptcha
  # This class enables detailed configuration of the recaptcha services.
  # 
  # By calling
  #
  #   Recaptcha.configuration # => instance of Recaptcha::Configuration
  #
  # or
  #   Recaptcha.configure do |config|
  #     config # => instance of Recaptcha::Configuration
  #   end
  #
  # you are able to perform configuration updates.
  #
  # Your are able to customize all attributes listed below. All values have
  # sensitive default and will very likely not need to be changed. 
  #
  # Please note that the public and private key for the reCAPTCHA API Access
  # have no useful default value. The keys may be set via the Shell enviroment
  # or using this configuration. Settings within this configuration always take
  # precedence.
  #
  # Setting the keys with this Configuration
  #
  #   Recaptcha.configure do |config|
  #     config.public_key  = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
  #     config.private_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
  #   end
  #
  class Configuration
    attr_accessor :nonssl_api_server_url,
                  :ssl_api_server_url,
                  :verify_url,
                  :skip_verify_env,
                  :private_key,
                  :public_key

    def initialize #:nodoc:
      @nonssl_api_server_url = RECAPTCHA_API_SERVER_URL
      @ssl_api_server_url    = RECAPTCHA_API_SECURE_SERVER_URL
      @verify_url            = RECAPTCHA_VERIFY_URL
      @skip_verify_env       = SKIP_VERIFY_ENV

      @private_key           = ENV['RECAPTCHA_PRIVATE_KEY']
      @public_key            = ENV['RECAPTCHA_PUBLIC_KEY']
    end

    def api_server_url(ssl = false) #:nodoc:
      ssl ? ssl_api_server_url : nonssl_api_server_url
    end
  end
end