Module: Kamcaptcha
- Defined in:
- lib/kamcaptcha.rb,
lib/kamcaptcha/token.rb,
lib/kamcaptcha/helper.rb,
lib/kamcaptcha/generator.rb,
lib/kamcaptcha/validation.rb
Overview
You must configure Kamcaptcha with a path to the generated words, and a salt. The salt must be the same you used when generating words.
Defined Under Namespace
Modules: Helper, Token, Validation Classes: Generator
Class Attribute Summary collapse
-
.path ⇒ Object
Returns the value of attribute path.
- .prefix ⇒ Object
-
.salt ⇒ Object
Returns the value of attribute salt.
-
.template ⇒ Object
Returns the value of attribute template.
Class Method Summary collapse
Class Attribute Details
.path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/kamcaptcha.rb', line 9 def path @path end |
.prefix ⇒ Object
12 13 14 |
# File 'lib/kamcaptcha.rb', line 12 def prefix @prefix || "" end |
.salt ⇒ Object
Returns the value of attribute salt.
9 10 11 |
# File 'lib/kamcaptcha.rb', line 9 def salt @salt end |
.template ⇒ Object
Returns the value of attribute template.
9 10 11 |
# File 'lib/kamcaptcha.rb', line 9 def template @template end |
Class Method Details
.encrypt(string) ⇒ Object
24 25 26 27 |
# File 'lib/kamcaptcha.rb', line 24 def encrypt(string) raise "You must configure a salt" if Kamcaptcha.salt.nil? Digest::SHA2.hexdigest("#{salt}::#{string}") end |
.images ⇒ Object
20 21 22 |
# File 'lib/kamcaptcha.rb', line 20 def images @images ||= Dir.glob("#{path}/*.*").map { |f| File.basename(f) } end |
.random ⇒ Object
16 17 18 |
# File 'lib/kamcaptcha.rb', line 16 def random images[rand(images.size)] end |