2015-10-26 13:55:46 +00:00
|
|
|
require 'rails'
|
|
|
|
require 'action_controller'
|
|
|
|
require 'active_support/all'
|
2015-10-26 06:09:39 +00:00
|
|
|
require_relative 'rucaptcha/version'
|
|
|
|
require_relative 'rucaptcha/configuration'
|
|
|
|
require_relative 'rucaptcha/controller_helpers'
|
|
|
|
require_relative 'rucaptcha/view_helpers'
|
2015-10-30 03:32:02 +00:00
|
|
|
require_relative 'rucaptcha/cache'
|
2015-10-26 09:40:59 +00:00
|
|
|
require_relative 'rucaptcha/captcha'
|
2015-10-26 06:09:39 +00:00
|
|
|
require_relative 'rucaptcha/engine'
|
|
|
|
|
|
|
|
module RuCaptcha
|
|
|
|
class << self
|
|
|
|
def config
|
|
|
|
return @config if defined?(@config)
|
|
|
|
@config = Configuration.new
|
2015-10-30 03:32:02 +00:00
|
|
|
@config.len = 4
|
2015-11-05 10:27:42 +00:00
|
|
|
@config.font_size = 45
|
2016-05-20 09:33:28 +00:00
|
|
|
@config.implode = 0.3
|
2015-10-30 03:32:02 +00:00
|
|
|
@config.cache_limit = 100
|
2016-03-14 08:41:27 +00:00
|
|
|
@config.expires_in = 2.minutes
|
2016-04-06 07:50:30 +00:00
|
|
|
@config.style = :colorful
|
2015-10-26 06:09:39 +00:00
|
|
|
@config
|
|
|
|
end
|
|
|
|
|
|
|
|
def configure(&block)
|
|
|
|
config.instance_exec(&block)
|
2015-10-30 03:32:02 +00:00
|
|
|
|
|
|
|
# enable cache if cache_limit less than 1
|
|
|
|
if config.cache_limit >= 1
|
|
|
|
RuCaptcha::Captcha.send(:include, RuCaptcha::Cache)
|
|
|
|
end
|
2015-10-26 06:09:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-30 03:32:02 +00:00
|
|
|
ActionController::Base.send(:include, RuCaptcha::ControllerHelpers)
|
|
|
|
ActionView::Base.send(:include, RuCaptcha::ViewHelpers)
|