2015-10-26 13:55:46 +00:00
|
|
|
require 'rails'
|
|
|
|
require 'action_controller'
|
|
|
|
require 'active_support/all'
|
2017-01-22 02:16:57 +00:00
|
|
|
require_relative 'rucaptcha/rucaptcha'
|
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 06:09:39 +00:00
|
|
|
require_relative 'rucaptcha/engine'
|
|
|
|
|
|
|
|
module RuCaptcha
|
|
|
|
class << self
|
|
|
|
def config
|
|
|
|
return @config if defined?(@config)
|
|
|
|
@config = Configuration.new
|
2016-04-06 07:50:30 +00:00
|
|
|
@config.style = :colorful
|
2017-01-22 02:16:57 +00:00
|
|
|
@config.expires_in = 2.minutes
|
2016-10-29 03:06:10 +00:00
|
|
|
if Rails.application
|
|
|
|
@config.cache_store = Rails.application.config.cache_store
|
|
|
|
else
|
|
|
|
@config.cache_store = :null_store
|
|
|
|
end
|
2015-10-26 06:09:39 +00:00
|
|
|
@config
|
|
|
|
end
|
|
|
|
|
|
|
|
def configure(&block)
|
|
|
|
config.instance_exec(&block)
|
|
|
|
end
|
2017-01-22 02:16:57 +00:00
|
|
|
|
|
|
|
def generate()
|
|
|
|
style = config.style == :colorful ? 1 : 0
|
|
|
|
self.create(style)
|
|
|
|
end
|
2015-10-26 06:09:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-30 03:32:02 +00:00
|
|
|
ActionController::Base.send(:include, RuCaptcha::ControllerHelpers)
|
|
|
|
ActionView::Base.send(:include, RuCaptcha::ViewHelpers)
|