rails_rate_limiter 0.2.1 → 0.3.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 +4 -4
- data/Gemfile.lock +18 -12
- data/lib/rails_rate_limiter/version.rb +1 -1
- data/lib/rails_rate_limiter.rb +8 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fd5bb10f6cff0e0d6d4d0a8d7c5ec288e4b33863674a31452976732bf02150e
|
4
|
+
data.tar.gz: 5dc24525086d671a6dac99b0c1031be29b006040242603e275fa80a213baaf8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f5ae74e6de4a4458af477975e3274f3d2a9afc434864d21c43a67d4ed800cbda6ada1a0fc319686a7e47f8a91d77abf236a75e35c9ab5cde54b05b82481e4cb
|
7
|
+
data.tar.gz: 1b8cd7c732e8f68ef24d8a22d97eb7466df179b5f3f745a4fe192c3ff73ce30d36a5bfd0eab7ceec683cd83475f109a3905a02d47afae5f949b8347dd07c3036
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_rate_limiter (0.
|
4
|
+
rails_rate_limiter (0.3.0)
|
5
5
|
rails (>= 4.2)
|
6
6
|
redis (>= 3.0)
|
7
7
|
|
@@ -53,11 +53,12 @@ GEM
|
|
53
53
|
builder (3.2.3)
|
54
54
|
coderay (1.1.2)
|
55
55
|
concurrent-ruby (1.0.5)
|
56
|
+
connection_pool (2.3.0)
|
56
57
|
crass (1.0.4)
|
57
58
|
diff-lcs (1.3)
|
58
59
|
erubi (1.7.1)
|
59
|
-
globalid (0.
|
60
|
-
activesupport (>=
|
60
|
+
globalid (1.0.0)
|
61
|
+
activesupport (>= 5.0)
|
61
62
|
i18n (1.0.1)
|
62
63
|
concurrent-ruby (~> 1.0)
|
63
64
|
loofah (2.2.2)
|
@@ -68,12 +69,14 @@ GEM
|
|
68
69
|
marcel (0.3.3)
|
69
70
|
mimemagic (~> 0.3.2)
|
70
71
|
method_source (0.9.0)
|
71
|
-
mimemagic (0.3.
|
72
|
-
|
72
|
+
mimemagic (0.3.10)
|
73
|
+
nokogiri (~> 1)
|
74
|
+
rake
|
75
|
+
mini_mime (1.1.2)
|
73
76
|
mini_portile2 (2.3.0)
|
74
77
|
minitest (5.11.3)
|
75
78
|
mock_redis (0.17.3)
|
76
|
-
nio4r (2.5.
|
79
|
+
nio4r (2.5.8)
|
77
80
|
nokogiri (1.8.2)
|
78
81
|
mini_portile2 (~> 2.3.0)
|
79
82
|
pry (0.11.3)
|
@@ -107,7 +110,10 @@ GEM
|
|
107
110
|
rake (>= 0.8.7)
|
108
111
|
thor (>= 0.18.1, < 2.0)
|
109
112
|
rake (10.5.0)
|
110
|
-
redis (
|
113
|
+
redis (5.0.5)
|
114
|
+
redis-client (>= 0.9.0)
|
115
|
+
redis-client (0.11.1)
|
116
|
+
connection_pool
|
111
117
|
rspec-core (3.7.1)
|
112
118
|
rspec-support (~> 3.7.0)
|
113
119
|
rspec-expectations (3.7.0)
|
@@ -125,18 +131,18 @@ GEM
|
|
125
131
|
rspec-mocks (~> 3.7.0)
|
126
132
|
rspec-support (~> 3.7.0)
|
127
133
|
rspec-support (3.7.1)
|
128
|
-
sprockets (4.
|
134
|
+
sprockets (4.1.1)
|
129
135
|
concurrent-ruby (~> 1.0)
|
130
136
|
rack (> 1, < 3)
|
131
|
-
sprockets-rails (3.
|
132
|
-
actionpack (>=
|
133
|
-
activesupport (>=
|
137
|
+
sprockets-rails (3.4.2)
|
138
|
+
actionpack (>= 5.2)
|
139
|
+
activesupport (>= 5.2)
|
134
140
|
sprockets (>= 3.0.0)
|
135
141
|
thor (0.20.0)
|
136
142
|
thread_safe (0.3.6)
|
137
143
|
tzinfo (1.2.5)
|
138
144
|
thread_safe (~> 0.1)
|
139
|
-
websocket-driver (0.7.
|
145
|
+
websocket-driver (0.7.5)
|
140
146
|
websocket-extensions (>= 0.1.0)
|
141
147
|
websocket-extensions (0.1.5)
|
142
148
|
|
data/lib/rails_rate_limiter.rb
CHANGED
@@ -57,10 +57,10 @@ module RailsRateLimiter
|
|
57
57
|
|
58
58
|
def check_rate_limits(strategy, limit, per, pattern, client, block)
|
59
59
|
requester = compute_requester_pattern(pattern || request.remote_ip)
|
60
|
-
|
60
|
+
limiter = compute_limit(limit)
|
61
61
|
strategy_class =
|
62
62
|
"RailsRateLimiter::Strategies::#{strategy.classify}".constantize
|
63
|
-
result = strategy_class.new(
|
63
|
+
result = strategy_class.new(limiter, per, requester, client).run
|
64
64
|
return unless result.limit_exceeded?
|
65
65
|
# instance_exec is using here because simple block.call executes block in
|
66
66
|
# a wrong context that leads to not preventing action execution after render
|
@@ -73,4 +73,10 @@ module RailsRateLimiter
|
|
73
73
|
# a wrong context that leads to not preventing action execution after render
|
74
74
|
"custom_#{instance_exec(&requester)}"
|
75
75
|
end
|
76
|
+
|
77
|
+
def compute_limit(limit)
|
78
|
+
return limit unless limit.respond_to?(:call)
|
79
|
+
|
80
|
+
instance_exec(&limit)
|
81
|
+
end
|
76
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_rate_limiter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Kotov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- rkotov93@gmail.com
|
114
114
|
executables: []
|
@@ -136,7 +136,7 @@ homepage: https://github.com/rkotov93/rails_rate_limiter
|
|
136
136
|
licenses:
|
137
137
|
- MIT
|
138
138
|
metadata: {}
|
139
|
-
post_install_message:
|
139
|
+
post_install_message:
|
140
140
|
rdoc_options: []
|
141
141
|
require_paths:
|
142
142
|
- lib
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
154
|
rubygems_version: 3.0.3
|
155
|
-
signing_key:
|
155
|
+
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Requests rate limiting library for Ruby on Rails
|
158
158
|
test_files: []
|