rucaptcha 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -8
- data/lib/rucaptcha.rb +1 -9
- data/lib/rucaptcha/captcha.rb +8 -2
- data/lib/rucaptcha/configuration.rb +1 -3
- data/lib/rucaptcha/controller_helpers.rb +1 -1
- data/lib/rucaptcha/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d38db9039dff4061dbd9e8b560dfe018b3d78a88
|
4
|
+
data.tar.gz: 3576b082261e0ee0efedf5b0726da34a10bc0313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6d14a6ec291107206e2ff3cc21f53e515d885ed4872e9a96cef822dec000201827d39906e79071bf66af0f5cd8ef799727aa2b15078e9278c6f5e487928830
|
7
|
+
data.tar.gz: 85dd5aac5b47060869a3fc23031dbf3801c9cb3cce605424a1dadf2604fbc195452acf73919d0894e533b1a01caff39b891605a2ce047e44e1e596fde7ecc9dc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,14 +37,7 @@ brew install imagemagick ghostscript
|
|
37
37
|
|
38
38
|
## Example
|
39
39
|
|
40
|
-

|
42
|
-

|
43
|
-

|
44
|
-

|
45
|
-

|
46
|
-

|
47
|
-

|
40
|
+
       
|
48
41
|
|
49
42
|
## Usage
|
50
43
|
|
data/lib/rucaptcha.rb
CHANGED
@@ -16,7 +16,7 @@ module RuCaptcha
|
|
16
16
|
@config = Configuration.new
|
17
17
|
@config.len = 4
|
18
18
|
@config.font_size = 45
|
19
|
-
@config.implode = 0.
|
19
|
+
@config.implode = 0.3
|
20
20
|
@config.cache_limit = 100
|
21
21
|
@config.expires_in = 2.minutes
|
22
22
|
@config.style = :colorful
|
@@ -26,14 +26,6 @@ module RuCaptcha
|
|
26
26
|
def configure(&block)
|
27
27
|
config.instance_exec(&block)
|
28
28
|
|
29
|
-
if config.width != nil
|
30
|
-
ActiveSupport::Deprecation.warn("RuCaptcha config.width will remove in 0.4.0")
|
31
|
-
end
|
32
|
-
|
33
|
-
if config.height != nil
|
34
|
-
ActiveSupport::Deprecation.warn("RuCaptcha config.height will remove in 0.4.0")
|
35
|
-
end
|
36
|
-
|
37
29
|
# enable cache if cache_limit less than 1
|
38
30
|
if config.cache_limit >= 1
|
39
31
|
RuCaptcha::Captcha.send(:include, RuCaptcha::Cache)
|
data/lib/rucaptcha/captcha.rb
CHANGED
@@ -5,13 +5,19 @@ module RuCaptcha
|
|
5
5
|
class << self
|
6
6
|
def random_color
|
7
7
|
if RuCaptcha.config.style == :colorful
|
8
|
-
[
|
8
|
+
color = [random_color_seed, random_color_seed, random_color_seed]
|
9
|
+
color[rand(3)] = 0.to_s(8)
|
10
|
+
color
|
9
11
|
else
|
10
12
|
color_seed = rand(50).to_s(8)
|
11
13
|
[color_seed, color_seed, color_seed]
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
17
|
+
def random_color_seed
|
18
|
+
(rand(150) + 10).to_s(8)
|
19
|
+
end
|
20
|
+
|
15
21
|
def random_chars
|
16
22
|
chars = SecureRandom.hex(RuCaptcha.config.len / 2).downcase
|
17
23
|
chars.gsub!(/[0ol1]/i, (rand(8) + 2).to_s)
|
@@ -35,7 +41,7 @@ module RuCaptcha
|
|
35
41
|
half_height = full_height / 2
|
36
42
|
text_top = 0
|
37
43
|
text_left = 0 - (font_size * 0.28).to_i
|
38
|
-
stroke_width = (font_size * 0.
|
44
|
+
stroke_width = (font_size * 0.05).to_i + 1
|
39
45
|
text_width = font_size + text_left
|
40
46
|
label = "=#{' ' * (chars.size - 1)}="
|
41
47
|
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module RuCaptcha
|
2
2
|
class Configuration
|
3
|
-
# TODO: remove height, width in 0.3.0
|
4
|
-
attr_accessor :height, :width
|
5
3
|
# Image font size, default 45
|
6
4
|
attr_accessor :font_size
|
7
5
|
# Number of chars, default 4
|
8
6
|
attr_accessor :len
|
9
|
-
# implode, default 0.
|
7
|
+
# implode, default 0.3
|
10
8
|
attr_accessor :implode
|
11
9
|
# Number of Captcha codes limit
|
12
10
|
# set 0 to disable limit and file cache, default: 100
|
@@ -20,7 +20,7 @@ module RuCaptcha
|
|
20
20
|
# Captcha chars in Session expire in 2 minutes
|
21
21
|
valid = false
|
22
22
|
if (Time.now.to_i - rucaptcha_at) <= RuCaptcha.config.expires_in
|
23
|
-
valid = captcha.present? && captcha == session
|
23
|
+
valid = captcha.present? && captcha == session.delete(:_rucaptcha)
|
24
24
|
end
|
25
25
|
|
26
26
|
if resource && resource.respond_to?(:errors)
|
data/lib/rucaptcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rucaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: posix-spawn
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.5.1
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: This is a Captcha gem for Rails Application. It run ImageMagick command to
|