Allow change chars length and disable strikethrough (#57)

This commit is contained in:
Rina authored and Jason Lee committed 2017-12-07 16:49:42 +08:00
1 parent 2ec5e9e8a6
commit 3939d1bb02
8 files changed
+131 -20

No files matched your search

+7 -1
View File
@@ -8,6 +8,7 @@ require 'rucaptcha/controller_helpers'
require 'rucaptcha/view_helpers'
require 'rucaptcha/cache'
require 'rucaptcha/engine'
require 'rucaptcha/errors/configuration'
module RuCaptcha
class << self
@@ -15,6 +16,8 @@ module RuCaptcha
return @config if defined?(@config)
@config = Configuration.new
@config.style = :colorful
@config.length = 5
@config.line = true
@config.expires_in = 2.minutes
if Rails.application
@config.cache_store = Rails.application.config.cache_store
@@ -31,7 +34,10 @@ module RuCaptcha
def generate()
style = config.style == :colorful ? 1 : 0
self.create(style)
length = config.length
raise Rucaptcha::Errors::Configuration, 'length config error, value must in 3..7' unless length.in?(3..7)
line = config.line ? 1 : 0
self.create(style, length, line)
end
def check_cache_store!
+5
View File
@@ -7,5 +7,10 @@ module RuCaptcha
attr_accessor :expires_in
# Color style, default: :colorful, allows: [:colorful, :black_white]
attr_accessor :style
# Captcha Digits: default 5, allows: [3,4,5,6,7]
attr_accessor :length
# rucaptcha line, default: true, allows: [true, false]
attr_accessor :line
end
end
+5
View File
@@ -0,0 +1,5 @@
module Rucaptcha
module Errors
class Configuration < StandardError; end
end
end
+1 -1
View File
@@ -1,3 +1,3 @@
module RuCaptcha
VERSION = '2.1.3'
VERSION = '2.1.4'
end