rucaptcha 0.5.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/rucaptcha/captcha.rb +21 -8
- data/lib/rucaptcha/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b8fc53f553af82a9e3c1ea5ff203058d1c94220
|
4
|
+
data.tar.gz: 675808db49191ce5c2396fa390fd764084557de6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 579416c175a280721232673ac4cc619fa76c9dd77b39d39cf4e0c203f31866b8476afe5ab00e3e53d711b0195b0c7e2080b77b6051aaa8bddb1efd5708a5080d
|
7
|
+
data.tar.gz: 5c8f783af7b9ef4909bf5fab282e35727d2c879c48021a2d5ec7cf3cae5bfd67edc1e72dc619f8f61cfbf24c0e6487aedb6157a3f88286f9586039ec2cfa3730
|
data/CHANGELOG.md
CHANGED
data/lib/rucaptcha/captcha.rb
CHANGED
@@ -5,19 +5,17 @@ module RuCaptcha
|
|
5
5
|
class << self
|
6
6
|
def random_color
|
7
7
|
if RuCaptcha.config.style == :colorful
|
8
|
-
|
9
|
-
|
8
|
+
color1 = rand(56) + 15
|
9
|
+
color2 = rand(10) + 140
|
10
|
+
color = [color1, color2, rand(15)]
|
11
|
+
color.shuffle!
|
10
12
|
color
|
11
13
|
else
|
12
|
-
color_seed = rand(
|
14
|
+
color_seed = rand(40) + 10
|
13
15
|
[color_seed, color_seed, color_seed]
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
|
-
def random_color_seed
|
18
|
-
(rand(150) + 10).to_s(8)
|
19
|
-
end
|
20
|
-
|
21
19
|
def random_chars
|
22
20
|
chars = SecureRandom.hex(RuCaptcha.config.len / 2).downcase
|
23
21
|
chars.gsub!(/[0ol1]/i, (rand(8) + 2).to_s)
|
@@ -44,8 +42,23 @@ module RuCaptcha
|
|
44
42
|
text_opts = []
|
45
43
|
line_opts = []
|
46
44
|
|
45
|
+
rgbs = []
|
46
|
+
chars.count.times do |i|
|
47
|
+
color = random_color
|
48
|
+
if i > 0
|
49
|
+
preview_color = rgbs[i - 1]
|
50
|
+
# Avoid color same as preview color
|
51
|
+
if color.index(color.min) == preview_color.index(preview_color.min) &&
|
52
|
+
color.index(color.max) == preview_color.index(preview_color.max)
|
53
|
+
# adjust RGB order
|
54
|
+
color = [color[1], color[2], color[0]]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rgbs << color
|
58
|
+
end
|
59
|
+
|
47
60
|
chars.each_with_index do |char, i|
|
48
|
-
rgb =
|
61
|
+
rgb = RuCaptcha.config.style == :colorful ? rgbs[i] : rgbs[0]
|
49
62
|
text_color = "rgba(#{rgb.join(',')}, 1)"
|
50
63
|
line_color = "rgba(#{rgb.join(',')}, 0.6)"
|
51
64
|
text_opts << %(-fill '#{text_color}' -draw 'text #{(text_left + text_width) * i + all_left},#{text_top} "#{char}"')
|
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
|
+
version: 1.0.0
|
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-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -47,7 +47,8 @@ files:
|
|
47
47
|
- lib/rucaptcha/version.rb
|
48
48
|
- lib/rucaptcha/view_helpers.rb
|
49
49
|
homepage: https://github.com/huacnlee/rucaptcha
|
50
|
-
licenses:
|
50
|
+
licenses:
|
51
|
+
- MIT
|
51
52
|
metadata: {}
|
52
53
|
post_install_message:
|
53
54
|
rdoc_options: []
|
@@ -57,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
58
|
requirements:
|
58
59
|
- - ">="
|
59
60
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
+
version: 1.9.0
|
61
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
63
|
requirements:
|
63
64
|
- - ">="
|
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
66
|
version: '0'
|
66
67
|
requirements: []
|
67
68
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.4.8
|
69
70
|
signing_key:
|
70
71
|
specification_version: 4
|
71
72
|
summary: This is a Captcha gem for Rails Application. It run ImageMagick command to
|