ft_gem 3.0.6 → 3.0.7
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/controllers/helpers.rb +1 -1
- data/lib/ft_gem/shared/ft_shared.rb +17 -19
- data/lib/ft_gem/view/helpers.rb +1 -1
- 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: 6c0a8c69dfe4aca10185946b59e1c84b43ea3f2e6eee1d77b7e3f1719036ea8c
|
4
|
+
data.tar.gz: fc6ec71ed903e2de999f205c2dde7e3fd20ffbe0ab8cdb31aa677c9f6319ef15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c1c9408359dc898477e9684d493212fe198eb0f50a6ea3fbfd71b4d7798e6cd0630f4d237d96cb1adb1d044a587dc5ac1a69a560c02457f9146d363ee5238d
|
7
|
+
data.tar.gz: 16f36295ed63115127b322827d3bd802bcdb6bf8e2a78c3a3cd6356e6dd9c9e1b4e5baa0d4a360ffcb4339199d4ce18cff2e7e81a9252a1af94c46e7344043c6
|
@@ -6,7 +6,7 @@ module FtGem
|
|
6
6
|
require 'base64'
|
7
7
|
|
8
8
|
def feature_toggle_status(name:)
|
9
|
-
toggles = FtShared.all_toggles
|
9
|
+
toggles = FtShared.new.all_toggles
|
10
10
|
update_feature_toggles(toggles: toggles)
|
11
11
|
decoded_cookie = Base64.decode64(cookies[TOGGLE_COOKIE_NAME])
|
12
12
|
index = toggles.index { |toggle| toggle['attributes']['name'] == name }
|
@@ -1,25 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/status", params: { name: name }).body.to_s)['data']
|
6
|
-
end
|
7
|
-
rescue StandardError => e
|
8
|
-
Rails.logger.error "FtHelper::fetch error #{e.backtrace}"
|
9
|
-
nil
|
1
|
+
class FtShared
|
2
|
+
def fetch(name:)
|
3
|
+
Rails.cache.fetch("feature-toggle-#{name}", expires_in: 1.minute) do
|
4
|
+
JSON.parse(HTTParty.get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/status", {query: { name: name },headers:authentication_header}).to_s)['data']
|
10
5
|
end
|
6
|
+
rescue StandardError => e
|
7
|
+
Rails.logger.error "FtHelper::fetch error #{e.backtrace}"
|
8
|
+
nil
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
rescue StandardError => e
|
17
|
-
Rails.logger.error "FtHelper::all_toggles error #{e.backtrace}"
|
18
|
-
{}
|
11
|
+
def all_toggles
|
12
|
+
Rails.cache.fetch('all-feature-toggles', expires_in: 1.minute) do
|
13
|
+
JSON.parse(HTTParty.get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/",{headers:authentication_header}).to_s)['data']
|
19
14
|
end
|
15
|
+
rescue StandardError => e
|
16
|
+
Rails.logger.error "FtHelper::all_toggles error #{e.backtrace}"
|
17
|
+
{}
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
20
|
+
def authentication_header
|
21
|
+
{ Authorization: "Bearer #{MumsnetJWT.tokenify}" }
|
24
22
|
end
|
25
23
|
end
|
data/lib/ft_gem/view/helpers.rb
CHANGED