rucaptcha 0.4.2 → 0.4.4

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: 3307c2eb78a6f7a75201b53a496ac8216ecf8993
4
- data.tar.gz: c3d88218528826086a0f1e3026b094eb6da60bae
3
+ metadata.gz: d38db9039dff4061dbd9e8b560dfe018b3d78a88
4
+ data.tar.gz: 3576b082261e0ee0efedf5b0726da34a10bc0313
5
5
  SHA512:
6
- metadata.gz: ff25973d8016612fff29df8ed00ae7f44adb3a8026c3a38672268da5cb02648f534e116b8dffd0eb3511bd17a2af440c1523f216f7e83bb76d903820bfdd6fba
7
- data.tar.gz: 27e49cfbf78f078a43641397d3d076c147de77dc071ee14b843961eee2eaf50089a114b15f1c60c7099604722354bdf5035933c9373625a5c9758923d19d1223
6
+ metadata.gz: dd6d14a6ec291107206e2ff3cc21f53e515d885ed4872e9a96cef822dec000201827d39906e79071bf66af0f5cd8ef799727aa2b15078e9278c6f5e487928830
7
+ data.tar.gz: 85dd5aac5b47060869a3fc23031dbf3801c9cb3cce605424a1dadf2604fbc195452acf73919d0894e533b1a01caff39b891605a2ce047e44e1e596fde7ecc9dc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.4.4
2
+
3
+ - Remove deprecated `width`, `height` config.
4
+ - Delete session key after verify (#23).
5
+ - Lighter text color, improve style.
6
+
1
7
  0.4.2
2
8
  -----
3
9
 
data/README.md CHANGED
@@ -37,14 +37,7 @@ brew install imagemagick ghostscript
37
37
 
38
38
  ## Example
39
39
 
40
- ![captcha8](https://cloud.githubusercontent.com/assets/5518/10965901/f8e17118-83ea-11e5-935d-a17fd6ab8307.png)
41
- ![captcha7](https://cloud.githubusercontent.com/assets/5518/10965903/f8e34b5a-83ea-11e5-9f8e-e43fc78347a7.png)
42
- ![captcha6](https://cloud.githubusercontent.com/assets/5518/10965902/f8e2f132-83ea-11e5-89f5-b75aedbcfb2f.png)
43
- ![captcha5](https://cloud.githubusercontent.com/assets/5518/10965904/f920ec44-83ea-11e5-89d2-3312da0f2bc4.png)
44
- ![captcha4](https://cloud.githubusercontent.com/assets/5518/10965905/f92264ac-83ea-11e5-96b0-2e81ee78d073.png)
45
- ![captcha3](https://cloud.githubusercontent.com/assets/5518/10965906/f9279652-83ea-11e5-94fa-a9cd2df9beec.png)
46
- ![captcha2](https://cloud.githubusercontent.com/assets/5518/10965909/f9623e24-83ea-11e5-8ad3-d4bf94edfe1b.png)
47
- ![captcha1](https://cloud.githubusercontent.com/assets/5518/10965908/f95fedfe-83ea-11e5-990b-fdcd2d1a97aa.png)
40
+ ![1](https://cloud.githubusercontent.com/assets/5518/15423974/b186b0d6-1eb2-11e6-9c0e-4cc3a66f32c8.png) ![2](https://cloud.githubusercontent.com/assets/5518/15423975/b1887b6e-1eb2-11e6-895f-5629f82697d3.png) ![3](https://cloud.githubusercontent.com/assets/5518/15423978/b18f08ee-1eb2-11e6-9670-c21dba290e04.png) ![4](https://cloud.githubusercontent.com/assets/5518/15423976/b18b6946-1eb2-11e6-8413-700ded157262.png) ![5](https://cloud.githubusercontent.com/assets/5518/15423977/b18e7c62-1eb2-11e6-96f7-5bd6981d4185.png) ![6](https://cloud.githubusercontent.com/assets/5518/15423979/b19175d4-1eb2-11e6-9417-7d496fb996b4.png) ![7](https://cloud.githubusercontent.com/assets/5518/15423980/b1caf944-1eb2-11e6-862e-78c0a9360b43.png) ![8](https://cloud.githubusercontent.com/assets/5518/15423981/b1d26f12-1eb2-11e6-9201-56b8d3f14063.png)
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.4
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)
@@ -5,13 +5,19 @@ module RuCaptcha
5
5
  class << self
6
6
  def random_color
7
7
  if RuCaptcha.config.style == :colorful
8
- [rand(100).to_s(8), rand(100).to_s(8), rand(100).to_s(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.08).to_i + 1
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.4
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[:_rucaptcha]
23
+ valid = captcha.present? && captcha == session.delete(:_rucaptcha)
24
24
  end
25
25
 
26
26
  if resource && resource.respond_to?(:errors)
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.4'
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.4.2
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-04-25 00:00:00.000000000 Z
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.6.3
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