forked from galetahub/simple-captcha
/
simple_captcha.rb
56 lines (43 loc) · 1.33 KB
/
simple_captcha.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# encoding: utf-8
module SimpleCaptcha
autoload :Utils, 'simple_captcha/utils'
autoload :ImageHelpers, 'simple_captcha/image'
autoload :ViewHelper, 'simple_captcha/view'
autoload :ControllerHelpers, 'simple_captcha/controller'
autoload :ModelHelpers, 'simple_captcha/active_record'
autoload :FormBuilder, 'simple_captcha/form_builder'
autoload :CustomFormBuilder, 'simple_captcha/formtastic'
autoload :SimpleCaptchaData, 'simple_captcha/simple_captcha_data'
autoload :Middleware, 'simple_captcha/middleware'
mattr_accessor :image_size
@@image_size = "100x28"
mattr_accessor :length
@@length = 5
# 'embosed_silver',
# 'simply_red',
# 'simply_green',
# 'simply_blue',
# 'distorted_black',
# 'all_black',
# 'charcoal_grey',
# 'almost_invisible'
# 'random'
mattr_accessor :image_style
@@image_style = 'simply_blue'
# 'low', 'medium', 'high', 'random'
mattr_accessor :distortion
@@distortion = 'low'
# command path
mattr_accessor :image_magick_path
@@image_magick_path = ''
# tmp directory
mattr_accessor :tmp_path
@@tmp_path = nil
def self.add_image_style(name, params = [])
SimpleCaptcha::ImageHelpers.image_styles.update(name.to_s => params)
end
def self.setup
yield self
end
end
require 'simple_captcha/engine' if defined?(Rails)