Module: EasyCaptcha
- Defined in:
- lib/easy_captcha.rb,
lib/easy_captcha/espeak.rb,
lib/easy_captcha/captcha.rb,
lib/easy_captcha/version.rb,
lib/easy_captcha/generator.rb,
lib/easy_captcha/controller.rb,
lib/easy_captcha/view_helpers.rb,
lib/easy_captcha/model_helpers.rb,
lib/easy_captcha/generator/base.rb,
lib/easy_captcha/generator/default.rb,
lib/easy_captcha/controller_helpers.rb,
lib/generators/easy_captcha/install_generator.rb
Overview
Captcha-Plugin for Rails
Defined Under Namespace
Modules: ControllerHelpers, Generator, Generators, ModelHelpers, ViewHelpers Classes: Captcha, Controller, Espeak
Constant Summary collapse
- VERSION =
'0.6.4'
- @@cache =
false
- @@cache_temp_dir =
nil
- @@cache_size =
500
- @@cache_expire =
nil
- @@chars =
%w(2 3 4 5 6 7 9 A C D E F G H J K L M N P Q R S T U X Y Z)
- @@length =
6
- @@image_width =
140
- @@image_height =
40
Class Method Summary collapse
-
.cache? ⇒ Boolean
:nodoc:.
- .espeak(&block) ⇒ Object
- .espeak=(state) ⇒ Object
- .espeak? ⇒ Boolean
-
.generator(generator = nil, &block) ⇒ Object
select generator and configure this.
-
.init ⇒ Object
called by rails after initialize.
-
.method_missing(name, *args) ⇒ Object
depracated.
-
.setup {|_self| ... } ⇒ Object
to configure easy_captcha for a sample look the readme.rdoc file.
Class Method Details
.cache? ⇒ Boolean
:nodoc:
53 54 55 |
# File 'lib/easy_captcha.rb', line 53 def cache? #:nodoc: cache end |
.espeak(&block) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/easy_captcha.rb', line 81 def espeak(&block) if block_given? @espeak = Espeak.new &block else @espeak ||= false end end |
.espeak=(state) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/easy_captcha.rb', line 73 def espeak=(state) if state === true @espeak = Espeak.new else @espeak = false end end |
.espeak? ⇒ Boolean
89 90 91 |
# File 'lib/easy_captcha.rb', line 89 def espeak? not espeak === false end |
.generator(generator = nil, &block) ⇒ Object
select generator and configure this
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/easy_captcha.rb', line 58 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 ⇒ Object
called by rails after initialize
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/easy_captcha.rb', line 116 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) ⇒ Object
depracated
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/easy_captcha.rb', line 94 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| ... } ⇒ Object
to configure easy_captcha for a sample look the readme.rdoc file
49 50 51 |
# File 'lib/easy_captcha.rb', line 49 def setup yield self end |