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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 117f0964bdce04506b9fb60fc4931ffc2c02473a89453fabd8412bb5a59f3a4f
4
- data.tar.gz: 498201bb936c10e4ecd5c7b970ef8945863c63ff559cbfca6a54767b76b760d7
3
+ metadata.gz: 39a9a9772dee5dba0e499afda4092932c5946c1d9f1eb82f4d30d02ea5c8a10a
4
+ data.tar.gz: 0543e9b71399df27e8505a72bbc57b55bbc90fea55ae61964107d2002d8c2b3d
5
5
  SHA512:
6
- metadata.gz: c9390c5c5794a2297769c062abc2963a1f874d70be9ac48ce810ed94858e8bafe24a3281a93520c71b0d156bd506704f85de96fd1c68b59865bfe2c2248cc192
7
- data.tar.gz: 8e9cc406410c589a0d5609898269d9dda1e6d4b1d7018452de35116fc59563b0959d45cca06617407cb1f6972645548aac8490d1082947ff37a5b242565c518f
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
- toggle = FtShared.fetch(name: name)
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 ) 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)
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("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/"))
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}"
@@ -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['feature_toggle']['toggle_percentage'].to_i == 100
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
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: 2.0.10
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Catto