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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31cead0cdd63b1aded016f970cd65c4c1ecccbb92d2d3c4f2bb8afda08a43624
4
- data.tar.gz: '03680bcf79b5b66ea5cb950685858af4a3517af3d5fd44ba7403be5b0e268b92'
3
+ metadata.gz: 6c0a8c69dfe4aca10185946b59e1c84b43ea3f2e6eee1d77b7e3f1719036ea8c
4
+ data.tar.gz: fc6ec71ed903e2de999f205c2dde7e3fd20ffbe0ab8cdb31aa677c9f6319ef15
5
5
  SHA512:
6
- metadata.gz: 1afebef5c926acd9e2cec987ec5a8c2ddd27f70775edbd6aa69d0875e8ed932d1ee397af8c40de760fa01759843a21471cb5b8f739ff4615ea0afabba44dcdba
7
- data.tar.gz: 063a8c79a7bac7181aebb2e92ae7b48d4f504ed5536cc0a065b55dc73c85a5239f80ecc8847a595d40dda5abad4e47b80317fed7cf0eb1266042b38804b13e8e
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
- module FtShared
2
- class <<self
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)['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
- 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/"))['data']
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
- def authentication_header
22
- { Authorization: "Bearer #{MumsnetJWT.tokenify}" }
23
- end
20
+ def authentication_header
21
+ { Authorization: "Bearer #{MumsnetJWT.tokenify}" }
24
22
  end
25
23
  end
@@ -2,7 +2,7 @@ module FtGem
2
2
  module View
3
3
  module Helpers
4
4
  def self.status(name:)
5
- toggle = FtShared.fetch(name: name)
5
+ toggle = FtShared.new.fetch(name: name)
6
6
  return false if toggle.nil?
7
7
  toggle['attributes']['percentage'].to_i == 100
8
8
  rescue StandardError => e
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: 3.0.6
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Catto