Module: QuickCaptcha
- Defined in:
- lib/quick_captcha/view_helpers.rb,
lib/quick_captcha.rb,
lib/quick_captcha/engine.rb,
lib/quick_captcha/version.rb,
lib/quick_captcha/captcha_utils.rb,
lib/quick_captcha/image_helpers.rb,
lib/quick_captcha/model_validation.rb,
lib/quick_captcha/quick_magick_backend.rb,
lib/quick_captcha/controller_validation.rb
Overview
Defined Under Namespace
Modules: CaptchaUtils, ControllerValidation, ImageHelpers, ModelValidation, QuickMagickBackend, VERSION, ViewHelpers
Classes: Engine
Constant Summary
collapse
- @@image_options =
{
:image_color => 'white',
:image_size => '110x30',
:text_color => 'black',
:text_font => 'arial',
:text_size => 22
}
- @@captcha_length =
nil
- @@backend =
nil
Class Method Summary
collapse
Class Method Details
.backend ⇒ Object
46
47
48
49
|
# File 'lib/quick_captcha.rb', line 46
def self.backend
self.backend = :quick_magick unless @@backend
@@backend
end
|
.backend=(backend) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/quick_captcha.rb', line 51
def self.backend=(backend)
if backend.nil?
return @@backend = nil
end
if backend.is_a?(Symbol) || backend.is_a?(String)
backend = backend.to_s.camelize
backend_const = const_get(backend + 'Backend') rescue nil
backend_const = const_get(backend) rescue nil unless backend_const
raise "unsupported backend: #{backend}" unless backend_const
else
backend_const = backend
end
unless backend_const.respond_to?(:generate_simple_captcha_image)
raise "invalid backend: #{backend_const} - does not respond to :generate_simple_captcha_image"
end
@@backend = backend_const
end
|
.captcha_length ⇒ Object
33
34
35
|
# File 'lib/quick_captcha.rb', line 33
def self.captcha_length
@@captcha_length ||= 6
end
|
.captcha_length=(length) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/quick_captcha.rb', line 37
def self.captcha_length=(length)
if length
raise "invalid captcha length < 0 : #{length}" if length <= 0
raise "invalid captcha length > 20 : #{length}" if length > 20
end
@@captcha_length = length
end
|
.image_options ⇒ Object
24
25
26
|
# File 'lib/quick_captcha.rb', line 24
def self.image_options
@@image_options
end
|
.image_options=(options) ⇒ Object
28
29
30
|
# File 'lib/quick_captcha.rb', line 28
def self.image_options=(options)
@@image_options.merge! options
end
|