ft_gem 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ft_gem_api.rb +19 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6ede7ab69a4b02afa727673767f0f3df8c45aa6c19bc4f65ca8d0bb8f840aea
|
4
|
+
data.tar.gz: 236e7d8ed28bdc9f15e3d6748bbf80238f82825d3d9cd612afe9f86edcf539a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc98e81e010862da4130d0c6c25e454b901a5c01800a3f26fbc3cd3abf686033d98b4483a3d6775cd567069d45ef8a8437281488bc315dbdabde590d563d6ce3
|
7
|
+
data.tar.gz: 8828505562b526cd29c1ac6b26a5a29f708ac46c4388036dcff3eae76fccc359c7265febc80381a6c2a1706ee85ee54f718cc564c58411fdfe5d3ef40698bbed
|
data/lib/ft_gem_api.rb
CHANGED
@@ -1,28 +1,26 @@
|
|
1
1
|
module FTGemApi
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
2
|
+
def feature_toggle_status(name:)
|
3
|
+
toggle = api_fetch_feature_toggle(name: name)
|
4
|
+
toggle['feature_toggle']['toggle_percentage'].to_i == 100
|
5
|
+
rescue StandardError => e
|
6
|
+
puts "FTApiGem error #{e}"
|
7
|
+
puts "Method: #{feature_toggle_status}"
|
8
|
+
false
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
rescue StandardError => e
|
17
|
-
puts "FTApiGem error #{e}"
|
18
|
-
puts "Method: #{feature_toggle_status}"
|
19
|
-
nil
|
11
|
+
def api_fetch_feature_toggle(name:)
|
12
|
+
Rails.cache.fetch("feature-toggle-#{name}", expires_in: 1.minute) do
|
13
|
+
JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/status", params: { name: name }).body.to_s)
|
20
14
|
end
|
15
|
+
rescue StandardError => e
|
16
|
+
puts "FTApiGem error #{e}"
|
17
|
+
puts "Method: #{feature_toggle_status}"
|
18
|
+
nil
|
19
|
+
end
|
21
20
|
|
22
|
-
|
21
|
+
private
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
23
|
+
def authentication_header
|
24
|
+
{ Authorization: "Bearer #{MumsnetJWT.tokenify}" }
|
27
25
|
end
|
28
26
|
end
|