rucaptcha 0.4.5 → 0.5.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 +6 -0
- data/lib/rucaptcha.rb +0 -5
- data/lib/rucaptcha/cache.rb +13 -15
- data/lib/rucaptcha/captcha.rb +1 -1
- data/lib/rucaptcha/engine.rb +7 -0
- data/lib/rucaptcha/version.rb +1 -1
- metadata +2 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c8619ffa153f60752223f1f764b7145849b1b4b
|
4
|
+
data.tar.gz: f7d6b3358ba52b86886550e41902cee4220bec28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2eebcabe01dca90464094dbd7bc367d09c7ab230c2f80a60acada970df844821affeb074ddfba828240576c7b9aa22ed6aed504a4144ce066ef2103580f301
|
7
|
+
data.tar.gz: 1f8a4758678ff5b44a94572db65ab6eb7040f451254b58dddeeddc8aa8e4b380805cbd27b994f8fa78f8fad0fb68ba74bb60b8b30ea65869d93bf0a808697915
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
0.5.0
|
2
|
+
|
3
|
+
- Fix cache with Rails 5.
|
4
|
+
|
1
5
|
0.4.5
|
6
|
+
-----
|
2
7
|
|
3
8
|
- Removed `posix-spawn` dependency, used open3 instead (core funciontality), JRuby compatible (#24)
|
4
9
|
|
5
10
|
0.4.4
|
11
|
+
-----
|
6
12
|
|
7
13
|
- Remove deprecated `width`, `height` config.
|
8
14
|
- Delete session key after verify (#23).
|
data/lib/rucaptcha.rb
CHANGED
data/lib/rucaptcha/cache.rb
CHANGED
@@ -3,30 +3,27 @@ require 'fileutils'
|
|
3
3
|
module RuCaptcha
|
4
4
|
# File Cache
|
5
5
|
module Cache
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
class << self
|
10
|
-
alias_method_chain :create, :cache
|
11
|
-
alias_method_chain :random_chars, :cache
|
6
|
+
def self.prepended(base)
|
7
|
+
class << base
|
8
|
+
prepend ClassMethods
|
12
9
|
end
|
13
10
|
end
|
14
11
|
|
15
12
|
module ClassMethods
|
16
|
-
def
|
17
|
-
cache.fetch(code) do
|
18
|
-
|
13
|
+
def create(code)
|
14
|
+
cache.fetch(code, expires_in: 1.days) do
|
15
|
+
super(code)
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
22
|
-
def
|
19
|
+
def random_chars
|
23
20
|
if cached_codes.length >= RuCaptcha.config.cache_limit
|
24
21
|
return cached_codes.sample
|
25
|
-
else
|
26
|
-
code = random_chars_without_cache
|
27
|
-
cached_codes << code
|
28
|
-
return code
|
29
22
|
end
|
23
|
+
|
24
|
+
code = super
|
25
|
+
cached_codes << code
|
26
|
+
code
|
30
27
|
end
|
31
28
|
|
32
29
|
def cache
|
@@ -35,7 +32,8 @@ module RuCaptcha
|
|
35
32
|
cache_path = Rails.root.join('tmp', 'cache', 'rucaptcha')
|
36
33
|
FileUtils.mkdir_p(cache_path) unless File.exist? cache_path
|
37
34
|
@cache = ActiveSupport::Cache::FileStore.new(cache_path)
|
38
|
-
|
35
|
+
# clear expired captcha cache files on Process restart
|
36
|
+
@cache.cleanup
|
39
37
|
@cache
|
40
38
|
end
|
41
39
|
|
data/lib/rucaptcha/captcha.rb
CHANGED
data/lib/rucaptcha/engine.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
module RuCaptcha
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace RuCaptcha
|
4
|
+
|
5
|
+
initializer 'rucaptcha.prepend.cache' do
|
6
|
+
# enable cache if cache_limit less than 1
|
7
|
+
if RuCaptcha.config.cache_limit >= 1
|
8
|
+
RuCaptcha::Captcha.send(:prepend, RuCaptcha::Cache)
|
9
|
+
end
|
10
|
+
end
|
4
11
|
end
|
5
12
|
end
|
data/lib/rucaptcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rucaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
@@ -9,49 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-05-25 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.3.0
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 3.3.0
|
12
|
+
dependencies: []
|
55
13
|
description:
|
56
14
|
email: huacnlee@gmail.com
|
57
15
|
executables: []
|