rucaptcha 0.3.3 → 0.4.0
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 +5 -0
- data/README.md +2 -0
- data/lib/rucaptcha.rb +1 -0
- data/lib/rucaptcha/captcha.rb +8 -3
- data/lib/rucaptcha/configuration.rb +2 -0
- 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: 4813b7de1b5db6258d3769bff600d64d30ffc3b3
|
4
|
+
data.tar.gz: 09591367c4a03a3071ffb1d8ca908a612251e646
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e986546c7c28b895340983ab7e7e774234a66e7460ed8f09d42bad1dfdd4794f237aa4f997974462a1cdba6bb9f1281610a26ceff345bfd5503022d083edf89
|
7
|
+
data.tar.gz: d2f6a6b72c0a9082b2c0151df7fd1bb3ddad88394e0c5f331719dd01752ebf7ab622bea3d277165a4e42869b67e15df903dc079b260dad1ff6decd3057f1aaff
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -67,6 +67,8 @@ RuCaptcha.configure do
|
|
67
67
|
self.cache_limit = 100
|
68
68
|
# Custom captcha code expire time if you need, default: 2 minutes
|
69
69
|
# self.expires_in = 120
|
70
|
+
# Color style, default: :colorful, allows: [:colorful, :black_white]
|
71
|
+
# self.style = :colorful
|
70
72
|
end
|
71
73
|
```
|
72
74
|
|
data/lib/rucaptcha.rb
CHANGED
data/lib/rucaptcha/captcha.rb
CHANGED
@@ -3,8 +3,13 @@ require 'posix-spawn'
|
|
3
3
|
module RuCaptcha
|
4
4
|
class Captcha
|
5
5
|
class << self
|
6
|
-
def
|
7
|
-
|
6
|
+
def random_color
|
7
|
+
if RuCaptcha.config.style == :colorful
|
8
|
+
[rand(100).to_s(8), rand(100).to_s(8), rand(100).to_s(8)]
|
9
|
+
else
|
10
|
+
color_seed = rand(50).to_s(8)
|
11
|
+
[color_seed, color_seed, color_seed]
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
def random_chars
|
@@ -37,7 +42,7 @@ module RuCaptcha
|
|
37
42
|
text_opts = []
|
38
43
|
line_opts = []
|
39
44
|
chars.each_with_index do |char, i|
|
40
|
-
rgb =
|
45
|
+
rgb = random_color
|
41
46
|
text_color = "rgba(#{rgb.join(',')}, 1)"
|
42
47
|
line_color = "rgba(#{rgb.join(',')}, 0.6)"
|
43
48
|
text_opts << %(-fill '#{text_color}' -draw 'text #{(text_left + text_width) * i + all_left},#{text_top} "#{char}"')
|
@@ -11,6 +11,8 @@ module RuCaptcha
|
|
11
11
|
# Number of Captcha codes limit
|
12
12
|
# set 0 to disable limit and file cache, default: 100
|
13
13
|
attr_accessor :cache_limit
|
14
|
+
# Color style, default: :colorful, allows: [:colorful, :black_white]
|
15
|
+
attr_accessor :style
|
14
16
|
# session[:_rucaptcha] expire time, default 2 minutes
|
15
17
|
attr_accessor :expires_in
|
16
18
|
end
|
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: 0.4.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-04-06 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.6.2
|
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
|