simple_throttle 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/MIT_LICENSE.txt +1 -1
- data/README.md +0 -1
- data/VERSION +1 -1
- data/lib/simple_throttle.rb +3 -1
- data/simple_throttle.gemspec +3 -3
- metadata +3 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bf38f023dce00a87b27e9b2f39d0519a8dbb4abd90b549697be21ed6792bd7f
|
4
|
+
data.tar.gz: 35023bd729899add113084518e63f8ee6975bf71c7a5b12fc0ceb64924ccd207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfab9a31ebc150ceb5f6b8833efc670357eefa790e60b33156607f7d72155566c300c454fc58368cae15936b8152f2c47e5ed83875ca3b8e0f58f9219d03d5e1
|
7
|
+
data.tar.gz: 4a3bd5605206b8b1e93bcc527c7d3f2dbf22590f23e390c4cb5c75ba7ac3cbe2fef885adffb62006fed54f310eea5804e10c6f319c81c45c8832971d36818718
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 1.0.7
|
8
|
+
|
9
|
+
## Fixed
|
10
|
+
- Fixed peek method to return the correct value rather than the raw value from Redis.
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- Updated repository location and gem owners
|
14
|
+
|
7
15
|
## 1.0.6
|
8
16
|
|
9
17
|
### Added
|
data/MIT_LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/0535eef45908cc64b740/maintainability)](https://codeclimate.com/github/weheartit/simple_throttle/maintainability)
|
2
1
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
3
2
|
|
4
3
|
This gem provides a very simple throttling mechanism backed by Redis for limiting access to a resource. The throttle can be thought of as a limit on the number of calls in a set time frame (i.e. 100 calls per hour).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.7
|
data/lib/simple_throttle.rb
CHANGED
@@ -157,7 +157,9 @@ class SimpleThrottle
|
|
157
157
|
#
|
158
158
|
# @return [Integer]
|
159
159
|
def peek
|
160
|
-
|
160
|
+
timestamps = redis_client.lrange(redis_key, 0, -1).collect(&:to_i)
|
161
|
+
min_timestamp = ((Time.now.to_f - ttl) * 1000).ceil
|
162
|
+
timestamps.count { |t| t > min_timestamp }
|
161
163
|
end
|
162
164
|
|
163
165
|
# Returns when the next resource call should be allowed. Note that this doesn't guarantee that
|
data/simple_throttle.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "simple_throttle"
|
3
3
|
spec.version = File.read(File.expand_path("../VERSION", __FILE__)).strip
|
4
|
-
spec.authors = ["
|
5
|
-
spec.email = ["
|
4
|
+
spec.authors = ["Brian Durand"]
|
5
|
+
spec.email = ["bbdurand@gmail.com"]
|
6
6
|
|
7
7
|
spec.summary = "Simple redis backed throttling mechanism to limit access to a resource"
|
8
|
-
spec.homepage = "https://github.com/
|
8
|
+
spec.homepage = "https://github.com/bdurand/simple_throttle"
|
9
9
|
spec.license = "MIT"
|
10
10
|
|
11
11
|
# Specify which files should be added to the gem when it is released.
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_throttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- We Heart It
|
8
7
|
- Brian Durand
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-31 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: redis
|
@@ -41,7 +40,6 @@ dependencies:
|
|
41
40
|
version: '0'
|
42
41
|
description:
|
43
42
|
email:
|
44
|
-
- dev@weheartit.com
|
45
43
|
- bbdurand@gmail.com
|
46
44
|
executables: []
|
47
45
|
extensions: []
|
@@ -53,7 +51,7 @@ files:
|
|
53
51
|
- VERSION
|
54
52
|
- lib/simple_throttle.rb
|
55
53
|
- simple_throttle.gemspec
|
56
|
-
homepage: https://github.com/
|
54
|
+
homepage: https://github.com/bdurand/simple_throttle
|
57
55
|
licenses:
|
58
56
|
- MIT
|
59
57
|
metadata: {}
|