ft_gem 2.0.10 → 3.0.0
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 +5 -10
- data/lib/ft_gem/shared/ft_shared.rb +4 -4
- 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: 39a9a9772dee5dba0e499afda4092932c5946c1d9f1eb82f4d30d02ea5c8a10a
|
4
|
+
data.tar.gz: 0543e9b71399df27e8505a72bbc57b55bbc90fea55ae61964107d2002d8c2b3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b01c628512e5425e03c07d30886249c84d3c2d278416942ff776e9acadfbcf17caf0b354130b2392f47726f35c83ea707ecfe59d51411e9f43460e5b7258f3c
|
7
|
+
data.tar.gz: cf2a4ed35b4dbbe1a324eba1bbf1246f7698554d0ee69804313754bde8af29d3128ec5cf35917bfd2bc8984691b497ed170eed9e3f1e2445c239363e35a67349
|
@@ -9,10 +9,10 @@ module FtGem
|
|
9
9
|
toggles = FtShared.all_toggles
|
10
10
|
update_feature_toggles(toggles: toggles)
|
11
11
|
decoded_cookie = Base64.decode64(cookies[TOGGLE_COOKIE_NAME])
|
12
|
-
index = toggles.index { |toggle| toggle['name'] == name }
|
12
|
+
index = toggles.index { |toggle| toggle['attributes']['name'] == name }
|
13
13
|
return false if index.nil?
|
14
14
|
client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: name)
|
15
|
-
toggle_percentage = toggles[index.to_i]['percentage']
|
15
|
+
toggle_percentage = toggles[index.to_i]['attributes']['percentage']
|
16
16
|
client_percentage.to_i <= toggle_percentage.to_i
|
17
17
|
rescue StandardError => e
|
18
18
|
Rails.logger.error "FtGem::feature_toggle_status error #{e.backtrace}"
|
@@ -24,8 +24,8 @@ module FtGem
|
|
24
24
|
decoded_cookie = Base64.decode64(cookies[TOGGLE_COOKIE_NAME])
|
25
25
|
new_cookie = []
|
26
26
|
toggles.each do |toggle|
|
27
|
-
client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: toggle['name'])
|
28
|
-
new_cookie.push("#{toggle['name']}:#{client_percentage}")
|
27
|
+
client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: toggle['attributes']['name'])
|
28
|
+
new_cookie.push("#{toggle['attributes']['name']}:#{client_percentage}")
|
29
29
|
end
|
30
30
|
cookies[TOGGLE_COOKIE_NAME] = Base64.encode64(new_cookie.join(','))
|
31
31
|
rescue StandardError => e
|
@@ -45,12 +45,7 @@ module FtGem
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def api_feature_toggle_status(name:)
|
48
|
-
|
49
|
-
return false if toggle.nil?
|
50
|
-
toggle['feature_toggle']['toggle_percentage'].to_i == 100
|
51
|
-
rescue StandardError => e
|
52
|
-
Rails.logger.error "FtGem::api_feature_toggle_status error #{e.backtrace}"
|
53
|
-
false
|
48
|
+
FtGem::View::Helpers.status(name: name)
|
54
49
|
end
|
55
50
|
end
|
56
51
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module FtShared
|
2
2
|
class <<self
|
3
3
|
def fetch(name:)
|
4
|
-
Rails.cache.fetch("feature-toggle-#{name}", expires_in: 1.minute
|
5
|
-
JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/status", params: { name: name }).body.to_s)
|
4
|
+
Rails.cache.fetch("feature-toggle-#{name}", expires_in: 1.minute) do
|
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
6
|
end
|
7
7
|
rescue StandardError => e
|
8
8
|
Rails.logger.error "FtHelper::fetch error #{e.backtrace}"
|
@@ -10,8 +10,8 @@ module FtShared
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def all_toggles
|
13
|
-
Rails.cache.fetch(
|
14
|
-
JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/"))
|
13
|
+
Rails.cache.fetch('all-feature-toggles', expires_in: 1.minute) do
|
14
|
+
JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/"))['data']
|
15
15
|
end
|
16
16
|
rescue StandardError => e
|
17
17
|
Rails.logger.error "FtHelper::all_toggles error #{e.backtrace}"
|
data/lib/ft_gem/view/helpers.rb
CHANGED
@@ -4,7 +4,7 @@ module FtGem
|
|
4
4
|
def self.status(name:)
|
5
5
|
toggle = FtShared.fetch(name: name)
|
6
6
|
return false if toggle.nil?
|
7
|
-
toggle['
|
7
|
+
toggle['attributes']['percentage'].to_i == 100
|
8
8
|
rescue StandardError => e
|
9
9
|
Rails.logger.error "FtHelper::status error #{e.backtrace}"
|
10
10
|
false
|