ft_gem 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ft_api_gem.rb +28 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 795c126093f3d47bdc01a4415945c9c37bff78d84ed1809f44f5dae0a44f3b73
|
4
|
+
data.tar.gz: ae277240613c03ad8104f47e82def1235ec41a65a507fde63f35acf16b2a977a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c1cc36e120f8b69850eb3e03e2ab3b27146b4c2cb4f76b815e5234a5aed96cefb8a0cf97b7092d5001b1c3a19adbc08f5ed3d08df400015f22558837aba814c
|
7
|
+
data.tar.gz: 946d302c902d9d537f190b0023680127b51f803624a2bb51fd2f47c641675941d153ed22e733ac50cfd5a4c45f66cfed8bd635c89aba8ff8510f3c9b505455e8
|
data/lib/ft_api_gem.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module FTApiGem
|
2
|
+
class << self
|
3
|
+
def feature_toggle_status(name:)
|
4
|
+
toggle = api_fetch_feature_toggle(name: name)
|
5
|
+
toggle['feature_toggle']['toggle_percentage'].to_i == 100
|
6
|
+
rescue StandardError => e
|
7
|
+
puts "FTApiGem error #{e}"
|
8
|
+
puts "Method: #{feature_toggle_status}"
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
def api_fetch_feature_toggle(name:)
|
13
|
+
Rails.cache.fetch("feature-toggle-#{name}", expires_in: 1.minute) do
|
14
|
+
JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/status", params: { name: name }).body.to_s)
|
15
|
+
end
|
16
|
+
rescue StandardError => e
|
17
|
+
puts "FTApiGem error #{e}"
|
18
|
+
puts "Method: #{feature_toggle_status}"
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def authentication_header
|
25
|
+
{ Authorization: "Bearer #{MumsnetJWT.tokenify}" }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ft_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Murray Catto
|
@@ -30,6 +30,7 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
+
- lib/ft_api_gem.rb
|
33
34
|
- lib/ft_gem.rb
|
34
35
|
homepage:
|
35
36
|
licenses: []
|