Sha256: 3c0dd60694c858d35e179c556e23e1d9bafe5a02aa70e52fbc61c7f1b5fe4712

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'yandex_captcha/configuration'
require 'yandex_captcha/verify'

module YandexCaptcha
  class NoApiKeyException < Exception; end
  class BadResponseException < Exception; end

  API_URL = 'http://cleanweb-api.yandex.ru/1.0'
  CAPTCHA_TYPE = 'std'
  HANDLE_TIMEOUTS_GRACEFULLY      = true
  SKIP_VERIFY_ENV = ['test', 'cucumber']

  # Gives access to the current Configuration.
  def self.configuration
    @configuration ||= Configuration.new
  end

  # Allows easy setting of multiple configuration options. See Configuration
  # for all available options.
  #--
  # The temp assignment is only used to get a nicer rdoc. Feel free to remove
  # this hack.
  #++
  def self.configure
    config = configuration
    yield(config)
  end

  def self.with_configuration(config)
    original_config = {}

    config.each do |key, value|
      original_config[key] = configuration.send(key)
      configuration.send("#{key}=", value)
    end

    result = yield if block_given?

    original_config.each { |key, value| configuration.send("#{key}=", value) }
    result
  end

  class YandexCleanwebError < StandardError
  end
end

if defined?(Rails)
  require 'yandex_captcha/rails'
end

if defined?(Sinatra) and Sinatra.respond_to? :register
  require 'yandex_captcha/sinatra'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yandex_captcha-0.4.0 lib/yandex_captcha.rb