Class: ReCaptcha::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/re_captcha/configuration.rb

Constant Summary collapse

API_END_POINT =
'https://www.google.com/recaptcha/'
SKIPPED_ENVIRONMENTS =
%w(test cucumber)
LANGUAGE_TABLE =
{
  'en-US' => 'en',
  'fr-FR' => 'fr',
  'es-ES' => 'es',
  'pt-PT' => 'pt-PT',
  'it-IT' => 'it',
  'en-GB' => 'en-GB',
  'de-DE' => 'de',
  'pt-BR' => 'pt-BR',
  'en-EU' => 'en-GB',
  'es-LA' => 'es-419',
  'zh-CN' => 'zh-CN',
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
# File 'lib/re_captcha/configuration.rb', line 22

def initialize
  @api_endpoint   = API_END_POINT
  @skipped_env    = SKIPPED_ENVIRONMENTS
  @public_key     = ENV['RECAPTCHA_PUBLIC_KEY']
  @private_key    = ENV['RECAPTCHA_PRIVATE_KEY']
  @language_table = LANGUAGE_TABLE
  @deny_on_error  = false
end

Instance Attribute Details

#api_endpointObject

Returns the value of attribute api_endpoint.



19
20
21
# File 'lib/re_captcha/configuration.rb', line 19

def api_endpoint
  @api_endpoint
end

#deny_on_errorObject

Returns the value of attribute deny_on_error.



19
20
21
# File 'lib/re_captcha/configuration.rb', line 19

def deny_on_error
  @deny_on_error
end

#language_tableObject

Returns the value of attribute language_table.



19
20
21
# File 'lib/re_captcha/configuration.rb', line 19

def language_table
  @language_table
end

#private_keyObject

Returns the value of attribute private_key.



19
20
21
# File 'lib/re_captcha/configuration.rb', line 19

def private_key
  @private_key
end

#public_keyObject

Returns the value of attribute public_key.



19
20
21
# File 'lib/re_captcha/configuration.rb', line 19

def public_key
  @public_key
end

#skipped_envObject

Returns the value of attribute skipped_env.



19
20
21
# File 'lib/re_captcha/configuration.rb', line 19

def skipped_env
  @skipped_env
end

Instance Method Details

#language_code(locale) ⇒ Object



31
32
33
# File 'lib/re_captcha/configuration.rb', line 31

def language_code(locale)
  @language_table[locale.to_s] || 'en'
end

#valid?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/re_captcha/configuration.rb', line 35

def valid?
  !private_key.nil? && !public_key.nil?
end