module EasyCaptcha
Captcha-Plugin for Rails
EasyCaptcha
module
Constants
- DEFAULT_CONFIG
- VERSION
Public Class Methods
captcha_code_length()
click to toggle source
# File lib/easy_captcha.rb, line 66 def captcha_code_length max = [captcha_character_count_min, captcha_character_count_max].max min = [captcha_character_count_min, captcha_character_count_max].min return (min..max).to_a.sample if captcha_character_count == :range captcha_character_count end
espeak(&block)
click to toggle source
# File lib/easy_captcha.rb, line 83 def espeak(&block) @espeak = Espeak.new(&block) if block_given? @espeak ||= false end
espeak=(state)
click to toggle source
# File lib/easy_captcha.rb, line 79 def espeak=(state) @espeak = state.is_a?(TrueClass) ? Espeak.new : false end
espeak?()
click to toggle source
# File lib/easy_captcha.rb, line 88 def espeak? !espeak.is_a?(FalseClass) end
generator(generator = nil, &block)
click to toggle source
select generator and configure this
# File lib/easy_captcha.rb, line 74 def generator(generator = nil, &block) resolve_generator(generator, &block) unless generator.nil? @generator end
init()
click to toggle source
# File lib/easy_captcha.rb, line 92 def init require 'easy_captcha/routes' ActiveRecord::Base.include ModelHelpers ActionController::Base.include ControllerHelpers ActionView::Base.include ViewHelpers # set default generator generator :default end
setup() { |self| ... }
click to toggle source
to configure easy_captcha for a sample look the readme.rdoc file
# File lib/easy_captcha.rb, line 55 def setup DEFAULT_CONFIG.map do |k, v| send("#{k}=", v) if respond_to? "#{k}=".to_sym end yield self if block_given? end
Private Class Methods
resolve_generator(generator, &block)
click to toggle source
# File lib/easy_captcha.rb, line 104 def resolve_generator(generator, &block) generator = generator.to_s if generator.is_a? Symbol if generator.is_a? String generator.gsub!(/^[a-z]|\s+[a-z]/, &:upcase) generator = "EasyCaptcha::Generator::#{generator}".constantize end @generator = generator.new(&block) end