rucaptcha 0.5.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fe1a21f8a2142b7b430c62264738016bf803c48
4
- data.tar.gz: de11fac7290c95d9e5b6a137bd88f9a9225ac8bd
3
+ metadata.gz: 0b8fc53f553af82a9e3c1ea5ff203058d1c94220
4
+ data.tar.gz: 675808db49191ce5c2396fa390fd764084557de6
5
5
  SHA512:
6
- metadata.gz: 2177bdc67c19738d3a953c73cc0891680500ed7492b7fa59d4f0f873d7d82f2df47175afd90310c9245b8230376fc6143985c6e488bfbee8388d4d48168a9ff6
7
- data.tar.gz: 0d69113ab3343156f6a74a860239f3cc9da6434aa3e3289b3f40804ab3cccb0f156c3c8bdaade59a10ad1cfe0be365d8fc30d8e332314f040e00e00ec0c7c5c0
6
+ metadata.gz: 579416c175a280721232673ac4cc619fa76c9dd77b39d39cf4e0c203f31866b8476afe5ab00e3e53d711b0195b0c7e2080b77b6051aaa8bddb1efd5708a5080d
7
+ data.tar.gz: 5c8f783af7b9ef4909bf5fab282e35727d2c879c48021a2d5ec7cf3cae5bfd67edc1e72dc619f8f61cfbf24c0e6487aedb6157a3f88286f9586039ec2cfa3730
@@ -1,3 +1,10 @@
1
+ 1.0.0
2
+ -----
3
+
4
+ - Adjust to avoid lighter colors.
5
+ - Avoid continuous chars have same color.
6
+ - Use same color for each chars in :black_white mode.
7
+
1
8
  0.5.1
2
9
  -----
3
10
 
@@ -5,19 +5,17 @@ module RuCaptcha
5
5
  class << self
6
6
  def random_color
7
7
  if RuCaptcha.config.style == :colorful
8
- color = [random_color_seed, random_color_seed, random_color_seed]
9
- color[rand(3)] = 0.to_s(8)
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(50).to_s(8)
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 = random_color
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}"')
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = '0.5.1'
2
+ VERSION = '1.0.0'
3
3
  end
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.5.1
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-06-22 00:00:00.000000000 Z
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: '0'
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.5.1
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