Module: RedisCaptcha

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

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"0.8.0"
@@redis_config =
{
  :host => "127.0.0.1",
  :port => 6379,
  :db => 0
}
@@redis_scope =
"RedisCaptcha"
@@expired_time =
1800
@@locked_times =
30
@@locked_time =
600
@@image_magick_path =
""
@@tempfile_path =
"/tmp"
@@tempfile_name =
"redis_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 =
"gary"
@@swirl_range =
{
  :max => 20,
  :min => -20
}
@@case_sensitive =
false
@@error_message =
"is invalid"

Class Method Summary collapse

Class Method Details

.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/redis_captcha.rb', line 96

def self.options
  @@options ||= {
    :redis_scope => redis_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

.redisObject



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

def self.redis
  @@redis ||= Redis.new(redis_config)
end

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

Yields:

  • (_self)

Yield Parameters:

  • _self (RedisCaptcha)

    the object that the method was called on



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

def self.setup
  yield self
end