rucaptcha/lib/rucaptcha.rb

39 lines
1.0 KiB
Ruby
Raw Normal View History

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'
require_relative 'rucaptcha/cache'
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
@config.len = 4
2015-11-05 10:27:42 +00:00
@config.font_size = 45
@config.implode = 0.3
@config.cache_limit = 100
@config.expires_in = 2.minutes
@config.style = :colorful
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
end
end
ActionController::Base.send(:include, RuCaptcha::ControllerHelpers)
ActionView::Base.send(:include, RuCaptcha::ViewHelpers)