ratelimit-ruby 0.1.5 → 0.1.6
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/VERSION +1 -1
- data/lib/ratelimit-ruby.rb +30 -2
- data/ratelimit-ruby.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f01c9e04b032a5ee94fb987336b241be8973cf
|
4
|
+
data.tar.gz: b1cc45bcbff577fd1f3a57a375dfe36cd3c245b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 490f788a9c1619dc26a7625f53989888a8201287592098065e84838be56b6f5ac90afa1e408ebd24ee728edebeff261bcfce3c86b0f2affa6c5eb81f3b22d083
|
7
|
+
data.tar.gz: 229bad14f83c45f9130b3e2794c85ac8131be2ed646fb0a066bbde66c7dd0b979279049e7985f2caab4d4aa62d2cb85d3c7b9e88dc8878a18580ae68203f750d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/ratelimit-ruby.rb
CHANGED
@@ -83,13 +83,27 @@ module RateLimit
|
|
83
83
|
|
84
84
|
def return(limit_result)
|
85
85
|
result = @conn.post '/api/v1/limitreturn',
|
86
|
-
|
87
|
-
|
86
|
+
{ enforcedGroup: limit_result.enforcedGroup,
|
87
|
+
amount: limit_result.amount }.to_json
|
88
88
|
handle_failure(result) unless result.success?
|
89
89
|
rescue => e
|
90
90
|
handle_error(e)
|
91
91
|
end
|
92
92
|
|
93
|
+
def feature_is_on?(feature)
|
94
|
+
feature_is_on_for?(feature, nil)
|
95
|
+
end
|
96
|
+
|
97
|
+
def feature_is_on_for?(feature, lookup_key, attributes: [])
|
98
|
+
to_send = { lookupKey: lookup_key, attributes: attributes }
|
99
|
+
result = @conn.get "/api/v1/featureflags/#{feature}/on", to_send
|
100
|
+
if result.success?
|
101
|
+
result.body == "true"
|
102
|
+
else
|
103
|
+
handle_feature_failure(result)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
93
107
|
private
|
94
108
|
|
95
109
|
def upsert(limit_definition, method)
|
@@ -135,6 +149,20 @@ module RateLimit
|
|
135
149
|
raise e
|
136
150
|
end
|
137
151
|
end
|
152
|
+
|
153
|
+
|
154
|
+
def handle_feature_failure(result)
|
155
|
+
case @on_error
|
156
|
+
when :log_and_pass
|
157
|
+
@logger.warn("returned #{result.status}")
|
158
|
+
true
|
159
|
+
when :log_and_hit
|
160
|
+
@logger.warn("returned #{result.status}")
|
161
|
+
false
|
162
|
+
when :throw
|
163
|
+
raise "#{result.status} calling feature flag RateLim.it"
|
164
|
+
end
|
165
|
+
end
|
138
166
|
end
|
139
167
|
|
140
168
|
end
|
data/ratelimit-ruby.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ratelimit-ruby 0.1.
|
5
|
+
# stub: ratelimit-ruby 0.1.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ratelimit-ruby"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Jeff Dwyer"]
|
14
|
-
s.date = "2017-01-
|
14
|
+
s.date = "2017-01-23"
|
15
15
|
s.description = "rate limit your ruby"
|
16
16
|
s.email = "jdwyah@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratelimit-ruby
|
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
|
- Jeff Dwyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|