better_rate_limit 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/better_rate_limit.rb +17 -0
- data/lib/better_rate_limit/configuration.rb +11 -0
- data/lib/better_rate_limit/throttle.rb +2 -0
- data/lib/better_rate_limit/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd081be677a01d7f69d7e6e6ada8a3172d84d6ee74fbf7ccab5d5fbecb89ee58
|
4
|
+
data.tar.gz: 2817642bfee1165564273b8b36ae434e02e7135c6e63a887a4c178c4558d3752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd3fda987a39c8027d47ddec7b6112e089a609aaabd3a924e71a76417619b69284416183d68744ea05fa55b47e1cead0d04cb99ddb33937e6db97f578d784db
|
7
|
+
data.tar.gz: 7b03b579af9be74f8669af5531d254580b0f384232dc5cb295f6d4cbcea7ca3525d42ee41105f0c08dd121c6a68d91544e06dd38a7044bd0b4062cc6007077c5
|
data/README.md
CHANGED
@@ -41,6 +41,15 @@ ActiveSupport::Notifications.subscribe /rate_limit/ do |_name, _start, _finish,
|
|
41
41
|
end
|
42
42
|
```
|
43
43
|
|
44
|
+
### Configuration
|
45
|
+
You can ignore the throttle by using the following configuration
|
46
|
+
```ruby
|
47
|
+
BetterRateLimit.configure do |config|
|
48
|
+
config.ignore = true
|
49
|
+
end
|
50
|
+
```
|
51
|
+
Useful to ignore the throttle on tests.
|
52
|
+
|
44
53
|
## Development
|
45
54
|
|
46
55
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/better_rate_limit.rb
CHANGED
@@ -1,4 +1,21 @@
|
|
1
1
|
require 'action_controller'
|
2
|
+
require 'better_rate_limit/configuration'
|
3
|
+
|
4
|
+
module BetterRateLimit
|
5
|
+
class << self
|
6
|
+
def configuration
|
7
|
+
@configuration ||= Configuration.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure
|
11
|
+
yield configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset_configuration
|
15
|
+
@configuration = Configuration.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
2
19
|
|
3
20
|
module ActionController
|
4
21
|
autoload :BetterRateLimit, 'action_controller/better_rate_limit'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_rate_limit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Fonseca
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- bin/setup
|
59
59
|
- lib/action_controller/better_rate_limit.rb
|
60
60
|
- lib/better_rate_limit.rb
|
61
|
+
- lib/better_rate_limit/configuration.rb
|
61
62
|
- lib/better_rate_limit/limit.rb
|
62
63
|
- lib/better_rate_limit/redis_connection.rb
|
63
64
|
- lib/better_rate_limit/throttle.rb
|
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
85
86
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
+
rubygems_version: 3.1.4
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: Rate limit requests
|