Class: SimpleCaptchaReloaded::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_captcha_reloaded/config.rb

Class Method Summary collapse

Class Method Details

.generate_challengeObject



27
28
29
30
31
32
33
# File 'lib/simple_captcha_reloaded/config.rb', line 27

def self.generate_challenge
  key = SecureRandom.uuid
  value = length.times.map do |i|
    characters.sample
  end
  [ key, value.join ]
end

.image_url(code, request) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/simple_captcha_reloaded/config.rb', line 8

def self.image_url(code, request)
  time = Time.now.to_i
  path = captcha_path + "?code=#{code}&time=#{time}"
  if request && defined?(request.protocol)
    "#{request.protocol}#{request.host_with_port}#{ENV['RAILS_RELATIVE_URL_ROOT']}#{path}"
  else
    "#{ENV['RAILS_RELATIVE_URL_ROOT']}#{path}"
  end
end

.refresh_url(request, id) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/simple_captcha_reloaded/config.rb', line 18

def self.refresh_url(request, id)
  path = captcha_path + "?id=#{id}"
  if request && defined?(request.protocol)
    "#{request.protocol}#{request.host_with_port}#{ENV['RAILS_RELATIVE_URL_ROOT']}#{path}"
  else
    "#{ENV['RAILS_RELATIVE_URL_ROOT']}#{path}"
  end
end