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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ft_api_gem.rb +28 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4ee4c596def6049f211b0c7a92f0c3b0c5d36c82d22541ccd4740931946a575
4
- data.tar.gz: c7ef0fa9cdbac6ae2a50d9f1765781234eef4844855a404a6a903bae71ba7363
3
+ metadata.gz: 795c126093f3d47bdc01a4415945c9c37bff78d84ed1809f44f5dae0a44f3b73
4
+ data.tar.gz: ae277240613c03ad8104f47e82def1235ec41a65a507fde63f35acf16b2a977a
5
5
  SHA512:
6
- metadata.gz: dc6e746737dbbe29ed9b4473492879121d460070165d2c51e78ba84b57692e757f80bbfae792eeb5baeab3f256a5587a6391b4df894cef6332dd7c4eab9b34ae
7
- data.tar.gz: fc6207c939536f4bf1311933659b0d7c98bf9eab747e6e50fce8b566d90ee7ea069aaf7d9428fee06a239d85172382d58ac18b33d6696b5887db2941d66cc0b8
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.1
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: []