Module: DalliCaptcha

Defined in:
lib/dalli_captcha.rb,
lib/dalli_captcha/image.rb,
lib/dalli_captcha/model.rb,
lib/dalli_captcha/engine.rb,
lib/dalli_captcha/version.rb,
lib/dalli_captcha/controller.rb,
lib/dalli_captcha/key_handler.rb,
lib/generators/install_generator.rb,
app/helpers/dalli_captcha/application_helper.rb,
app/controllers/dalli_captcha/captcha_controller.rb,
app/controllers/dalli_captcha/application_controller.rb

Defined Under Namespace

Modules: ApplicationHelper, Controller, Generators, Model Classes: ApplicationController, CaptchaController, Engine, Image, KeyHandler

Constant Summary collapse

VERSION =
"0.0.3"
@@dalli_config =
{
  :host => "localhost:11211",
  :compress => true,
  :namespace => "captcha"
}
@@dalli_scope =
"DalliCaptcha"
@@expired_time =
1800
@@locked_times =
30
@@locked_time =
600
@@image_magick_path =
""
@@tempfile_path =
"/tmp"
@@tempfile_name =
"dalli_captcha"
@@tempfile_type =
".png"
@@content_type =
"image/png"
@@width =
120
@@height =
30
@@chars =
%w(2 3 4 5 6 7 9 a b c d e f g h j k m n p q r s t w x y z A C D E F G H J K L M N P Q R S T X Y Z)
@@string_length =
{
  :max => 6,
  :min => 4
}
@@font_color =
"gray"
@@background =
"white"
@@line =
{
  :max => 4,
  :min => 2
}
@@line_color =
"gray"
@@swirl_range =
{
  :max => 20,
  :min => -20
}
@@case_sensitive =
false
@@error_message =
"is invalid"

Class Method Summary collapse

Class Method Details

.dalliObject



92
93
94
# File 'lib/dalli_captcha.rb', line 92

def self.dalli
  @@dalli ||= Dalli::Client.new(dalli_config.delete(:host),dalli_config)
end

.optionsObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/dalli_captcha.rb', line 96

def self.options
  @@options ||= {
    :dalli_scope => dalli_scope,
    :expired_time => expired_time,
    :locked_times => locked_times,
    :locked_time => locked_time,
    :image_magick_path => image_magick_path,
    :tempfile_path => tempfile_path,
    :tempfile_name => tempfile_name,
    :tempfile_type => tempfile_type,
    :content_type => content_type,
    :width => width,
    :height => height,
    :chars => chars,
    :string_length => string_length,
    :font_color => font_color,
    :background => background,
    :line => line,
    :line_color => line_color,
    :swirl_range => swirl_range,
    :case_sensitive => case_sensitive,
    :error_message => error_message
  }
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (DalliCaptcha)

    the object that the method was called on



88
89
90
# File 'lib/dalli_captcha.rb', line 88

def self.setup
  yield self
end