ft_gem 3.1.12 → 3.2.3

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: c0e2da07f3d2533e273a4c2b299dc80c3fe95cf2d6dd30f84c2258a3a2ae6b22
4
- data.tar.gz: 9eeca9dbd37d564fa512ed2cfec993af971911878ad46c54d4d573400a7e37a7
3
+ metadata.gz: b333c05567a5be9cc6d934ba301abc34c0b20d71423b4c9bd74b2b4785b0f5ba
4
+ data.tar.gz: 67b80f508437e2ffaa342eefac5685091d684dc98662e2340fc98bdb80f61c24
5
5
  SHA512:
6
- metadata.gz: 4a55724fd18a65cb6d31d82bcb74951d36727bd9d7e7331ccfa624695724d346ff3b521afecec209f668becf8a59be0fb344f9cfd7ef655f80120928184c88d5
7
- data.tar.gz: 637e41c423d27e01e4fe40fb810f307acbefacc4d00b58f24257a4502c3f2dc3bcc4a5382fff94a4e87e874b5c8cb9b783562fd22b912381589cc7bb60a3d236
6
+ metadata.gz: 7938240f6c14e58801e9ab5f5d2075db179e7655395a1592b700e45596ebac80c886df56279009e852918ea1a01ebcffe5471c0312cbafd8582092e3d60b5f26
7
+ data.tar.gz: 764fbf30382d7ca98d72c0427ea2c4f5f60fdcd2ef9b6dfa977c1e8cfeb56a44af208151cc239388e3973c878eac2b587bdd9e010da47ab7ee30e9f7a2f58c71
@@ -8,16 +8,20 @@ module FtGem
8
8
 
9
9
  def feature_toggle_status(name:, user_id: nil, url: nil)
10
10
  toggles = FtShared.new.all_toggles
11
- update_feature_toggles(toggles: toggles)
12
- decoded_cookie = Base64.decode64(cookies[TOGGLE_COOKIE_NAME])
13
11
  index = toggles.index { |toggle| toggle['attributes']['name'] == name }
14
12
  return false if index.nil?
15
- client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: name)
16
- toggle_percentage = toggles[index.to_i]['attributes']['percentage']
13
+
17
14
  whitelisted = FtShared.new.whitelisted?(url: url, whitelist_urls: toggles[index.to_i]['attributes']['whitelist-urls'])
15
+ return false unless whitelisted
16
+
17
+ return true if FtGem::Services::BetaService.public_beta?(cookie: cookies[PUBLICBETA_COOKIE_NAME], toggles: toggles, index: index)
18
+ return true if FtGem::Services::BetaService.private_beta?(user_id: user_id, toggles: toggles, index: index)
18
19
 
19
- return true && whitelisted if FtGem::Services::BetaService.public_beta(cookie: Base64.decode64(cookies[PUBLICBETA_COOKIE_NAME]),toggles: toggles, index: index)
20
- return true && whitelisted if FtGem::Services::BetaService.private_beta(user_id: user_id, toggles: toggles, index: index)
20
+ update_feature_toggles(toggles: toggles)
21
+ decoded_cookie = Base64.decode64(cookies[TOGGLE_COOKIE_NAME])
22
+
23
+ client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: name)
24
+ toggle_percentage = toggles[index.to_i]['attributes']['percentage']
21
25
 
22
26
  return client_percentage.to_i <= toggle_percentage.to_i && whitelisted
23
27
  rescue StandardError => e
@@ -7,14 +7,17 @@ module FtGem
7
7
 
8
8
  attributes = toggles[index.to_i].dig('attributes')
9
9
 
10
+ Rails.logger.info("########### PRIVATE BETA status: #{attributes['status']}, include users: #{attributes['beta-users'].split(",").include?(user_id.to_s)} ################")
10
11
  attributes['status'] == "privatebeta" && attributes['beta-users'].split(",").include?(user_id.to_s)
11
12
  end
12
13
 
13
- def self.public_beta?(cookie: "", toggles: nil, index: "")
14
+ def self.public_beta?(cookie: nil, toggles: nil, index: "")
14
15
  return false unless toggles.present?
15
16
 
16
17
  attributes = toggles.dig(index.to_i, 'attributes')
17
- cookie == "true" && attributes['status'] == "publicbeta"
18
+
19
+ Rails.logger.info("########### PUBLIC BETA cookie: #{cookie}, status: #{attributes['status']} ################")
20
+ attributes['status'] == "publicbeta" && cookie.present?
18
21
  end
19
22
  end
20
23
  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: 3.1.12
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Catto