rucaptcha 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ada49e11068101a36ddaa013cfd4f27cc424778e
4
- data.tar.gz: 06ceaea4535e0ac78e327fb20ec976ed8d5282d6
3
+ metadata.gz: 4813b7de1b5db6258d3769bff600d64d30ffc3b3
4
+ data.tar.gz: 09591367c4a03a3071ffb1d8ca908a612251e646
5
5
  SHA512:
6
- metadata.gz: 3b02d25df3976d381077272bae3a77f7a10398e3d359206eb40283df983cc1f805969707c3044fabb6ebd0db26fa99dff5f034ce36aba025892489595ad365e7
7
- data.tar.gz: e4075f1cf9642c44f0a1b1ad1bafe65f47920d0bb3f69ebab08e156333191f4fa58cf0a52456d8dee4cc6c25d249f16d899ab7e9ca12a3e3984ad9e4c5c10cc7
6
+ metadata.gz: 7e986546c7c28b895340983ab7e7e774234a66e7460ed8f09d42bad1dfdd4794f237aa4f997974462a1cdba6bb9f1281610a26ceff345bfd5503022d083edf89
7
+ data.tar.gz: d2f6a6b72c0a9082b2c0151df7fd1bb3ddad88394e0c5f331719dd01752ebf7ab622bea3d277165a4e42869b67e15df903dc079b260dad1ff6decd3057f1aaff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.4.0
2
+ -----
3
+
4
+ - Add `config.colorize` option, to allow use black text theme.
5
+
1
6
  0.3.3
2
7
  -----
3
8
 
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
@@ -19,6 +19,7 @@ module RuCaptcha
19
19
  @config.implode = 0.4
20
20
  @config.cache_limit = 100
21
21
  @config.expires_in = 2.minutes
22
+ @config.style = :colorful
22
23
  @config
23
24
  end
24
25
 
@@ -3,8 +3,13 @@ require 'posix-spawn'
3
3
  module RuCaptcha
4
4
  class Captcha
5
5
  class << self
6
- def rand_color
7
- [rand(100).to_s(8), rand(100).to_s(8), rand(100).to_s(8)]
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 = rand_color
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
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = '0.3.3'
2
+ VERSION = '0.4.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.3.3
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-03-15 00:00:00.000000000 Z
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.5.1
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