racaptcha 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: a80c7408ad417d8f3fea20f1d934334f37de3289fc90165d16f23b3c84715d13
4
- data.tar.gz: f1d66f613aee6a35590db8ead09bb92cebe8bb75e44f371c80290eeaf2e3597d
3
+ metadata.gz: bd350dc677de5fe1ce13a3eba19cd6fc13c30a9c1b44bc637159052048ad7546
4
+ data.tar.gz: 9d96dfa982a4ad938527503b7d016d0676dca65b549130a49386f14e680590ec
5
5
  SHA512:
6
- metadata.gz: 4ef9ca7b1aa9eef11426535e5c09e3ce64325e5674c691c1e3c2e87d42980c5ec1082262c2cd73c6ae6ba934f3919134709e8921a78de01517e2841cd5e1d3ac
7
- data.tar.gz: 22c419b540e631434119e0bc6903f4c564493d4154a7d805c9afa4b20dffb6193b9713fedbfc26e412adc5d0b78b23b7e45e1163638d2d1e2239f1f03966de40
6
+ metadata.gz: eb0b70aa4e1eba0163423978537baa80db9b454240181b12b6d281a5049b7d5cb5e96bb526c6433784e79ce4981c259f307d02ce8a1de4260d6e50db47cdd13c
7
+ data.tar.gz: de457a2212c8ea03e03cf16a571be3746dbe7b57c2d09915135c84ee3d244fa34a262d6d11fb313bbbe44336cbd9ebdf77cd19c1459416440502e133ad691d04
data/Gemfile.lock CHANGED
@@ -1,29 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- racaptcha (0.1.0)
5
- activesupport (>= 5.0)
4
+ racaptcha (0.2.2)
5
+ activesupport (>= 5.2.4.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.2.2)
10
+ activesupport (6.1.5)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (>= 0.7, < 2)
13
- minitest (~> 5.1)
14
- tzinfo (~> 1.1)
15
- zeitwerk (~> 2.2)
16
- concurrent-ruby (1.1.6)
17
- i18n (1.8.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ zeitwerk (~> 2.3)
16
+ concurrent-ruby (1.1.10)
17
+ i18n (1.10.0)
18
18
  concurrent-ruby (~> 1.0)
19
- minitest (5.14.0)
19
+ minitest (5.15.0)
20
20
  rake (13.0.1)
21
21
  rake-compiler (1.1.0)
22
22
  rake
23
- thread_safe (0.3.6)
24
- tzinfo (1.2.7)
25
- thread_safe (~> 0.1)
26
- zeitwerk (2.3.0)
23
+ tzinfo (2.0.4)
24
+ concurrent-ruby (~> 1.0)
25
+ zeitwerk (2.5.4)
27
26
 
28
27
  PLATFORMS
29
28
  ruby
@@ -33,4 +32,4 @@ DEPENDENCIES
33
32
  rake-compiler (~> 1)
34
33
 
35
34
  BUNDLED WITH
36
- 2.0.1
35
+ 2.3.12
@@ -15,5 +15,25 @@ module RaCaptcha
15
15
  attr_accessor :outline
16
16
  # skip_cache_store_check, default: false
17
17
  attr_accessor :skip_cache_store_check
18
+
19
+ def initialize
20
+ @cache_store = :file_store
21
+ @expires_in = 2.minutes
22
+ @style = :colorful
23
+ @length = 5
24
+ @strikethrough = true
25
+ @outline = false
26
+ @skip_cache_store_check = false
27
+ end
28
+ end
29
+
30
+ class << self
31
+ def setup
32
+ yield config
33
+ end
34
+
35
+ def config
36
+ @config ||= Configuration.new
37
+ end
18
38
  end
19
39
  end
@@ -1,3 +1,3 @@
1
1
  module RaCaptcha
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/racaptcha.rb CHANGED
@@ -1,35 +1,16 @@
1
1
  require "active_support/all"
2
- require "racaptcha/racaptcha"
3
- require "racaptcha/version"
4
2
  require "racaptcha/configuration"
3
+ require "racaptcha/version"
5
4
  require "racaptcha/errors/configuration"
5
+ require "racaptcha/racaptcha"
6
6
 
7
7
  module RaCaptcha
8
8
  class << self
9
- def config
10
- return @config if defined?(@config)
11
-
12
- @config = Configuration.new
13
- @config.style = :colorful
14
- @config.length = 5
15
- @config.strikethrough = true
16
- @config.outline = false
17
- @config.expires_in = 2.minutes
18
- @config.skip_cache_store_check = false
19
-
20
- @config.cache_store = :file_store
21
- @config.cache_store
22
- @config
23
- end
24
-
25
- def setup(&block)
26
- config.instance_exec(&block)
27
- end
28
9
 
29
10
  def cache
30
11
  return @cache if defined? @cache
31
12
 
32
- @cache = ActiveSupport::Cache.lookup_store(RaCaptcha.config.cache_store)
13
+ @cache = ActiveSupport::Cache.lookup_store(config.cache_store)
33
14
  @cache
34
15
  end
35
16
 
@@ -49,12 +30,12 @@ module RaCaptcha
49
30
 
50
31
  # generate new captcha with cache
51
32
  def generate_captcha(cache_key = nil)
52
- res = RaCaptcha.generate
33
+ res = generate
53
34
  _val = {
54
35
  code: res[0],
55
36
  time: Time.now.to_i
56
37
  }
57
- RaCaptcha.cache.write(generate_cache_key(cache_key), _val, expires_in: RaCaptcha.config.expires_in)
38
+ cache.write(generate_cache_key(cache_key), _val, expires_in: config.expires_in)
58
39
  res[1]
59
40
  end
60
41
 
@@ -69,15 +50,15 @@ module RaCaptcha
69
50
  options ||= {}
70
51
 
71
52
  _key = generate_cache_key(options[:cache_key])
72
- store_info = RaCaptcha.cache.read(_key)
53
+ store_info = cache.read(_key)
73
54
  # Make sure move used key
74
- RaCaptcha.cache.delete(_key) unless options[:keep_cache]
55
+ cache.delete(_key) unless options[:keep_cache]
75
56
 
76
57
  # Make sure session exist
77
58
  return false if store_info.blank?
78
59
 
79
60
  # Make sure not expire
80
- return false if (Time.now.to_i - store_info[:time]) > RaCaptcha.config.expires_in
61
+ return false if (Time.now.to_i - store_info[:time]) > config.expires_in
81
62
 
82
63
  # Make sure have captcha
83
64
  captcha = (options[:captcha] || "").downcase.strip
data/racaptcha.gemspec CHANGED
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
38
38
  spec.required_ruby_version = ">= 2.0.0"
39
39
  spec.extensions = %w[ext/racaptcha/extconf.rb]
40
40
 
41
- spec.add_runtime_dependency 'activesupport', '>= 5.0'
41
+ spec.add_runtime_dependency 'activesupport', '>= 5.2.4.3'
42
42
  spec.add_development_dependency 'rake-compiler', '~> 1'
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: racaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - wangrui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: 5.2.4.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: 5.2.4.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake-compiler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -89,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.7.11
92
+ rubygems_version: 3.0.3
94
93
  signing_key:
95
94
  specification_version: 4
96
95
  summary: This is a Captcha gem for ruby.