module EasyCaptcha

Captcha-Plugin for Rails

Constants

VERSION

Public Class Methods

espeak(&block) click to toggle source
# File lib/easy_captcha.rb, line 80
def espeak(&block)
  if block_given?
    @espeak = Espeak.new &block
  else
    @espeak ||= false
  end
end
espeak=(state) click to toggle source
# File lib/easy_captcha.rb, line 72
def espeak=(state)
  if state === true
    @espeak = Espeak.new
  else
    @espeak = false
  end
end
espeak?() click to toggle source
# File lib/easy_captcha.rb, line 88
def espeak?
  not espeak === false
end
generator(generator = nil, &block) click to toggle source

select generator and configure this

# File lib/easy_captcha.rb, line 57
def generator(generator = nil, &block)
  if generator.nil?
    @generator
  else
    generator = generator.to_s if generator.is_a? Symbol

    if generator.is_a? String
      generator.gsub!(/^[a-z]|\s+[a-z]/) { |a| a.upcase }
      generator = "EasyCaptcha::Generator::#{generator}".constantize
    end

    @generator = generator.new &block
  end
end
init() click to toggle source

called by rails after initialize

# File lib/easy_captcha.rb, line 115
def init
  require 'easy_captcha/routes'
  ActiveRecord::Base.send :include, ModelHelpers
  ActionController::Base.send :include, ControllerHelpers
  ActionView::Base.send :include, ViewHelpers

  # set default generator
  generator :default

end
method_missing(name, *args) click to toggle source

depracated

Calls superclass method
# File lib/easy_captcha.rb, line 93
def method_missing name, *args
  name = name.to_s # fix for jruby
  depracations = [
      :font_size, :font_fill_color, :font_family, :font_stroke, :font_stroke_color,
      :image_background_color, :sketch, :sketch_radius, :sketch_sigma, :wave,
      :wave_length, :wave_amplitude, :implode, :blur, :blur_radius, :blur_sigma
  ]

  if depracations.include? name[0..-2].to_sym or depracations.include? name.to_sym
    ActiveSupport::Deprecation.warn "EasyCaptcha.#{name} is deprecated."
    if name[-1,1] == '='
      self.generator.send(name, args.first)
    else
      self.generator.send(name)
    end
  else
    super
  end
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 48
def setup
  yield self
end