ft_gem 3.1.10 → 3.2.1

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: 21b45e240a1861569b16e5e45a0b1d660511981dec84d6e4c75f2885a1e52225
4
- data.tar.gz: 2c32bcf43c396dcdf24fb07d982476c0135967a2d19ba8dd9db42bead064c68e
3
+ metadata.gz: 35400c0fa6a2f7640b62ae165101ed26afac0c10bcacdca9bc4d0adcef9b827b
4
+ data.tar.gz: c34b83cdd99f07730de5c3942cd6bcbf21ad49b72d48160824ade5f9f6e80880
5
5
  SHA512:
6
- metadata.gz: e118c452267dc979e61bf8c1745fc09c83f86e5f295d3fcaf0e4da84e7356d320efdc9497a02675489dc7a0900c26a3e77fd25ee5aca2210c9a60facbd58e2b9
7
- data.tar.gz: 6e268ed09221c2bd491c5f3fa668cc060661a9557f49f8d234cbb13bf2bf261a9285b76ea85335bac241f6dc6109a81cbaeaf7ed96c4b45e8b68d989c4a0fb8b
6
+ metadata.gz: 545f3a715845a5e452e6340d3d737fe23afb3843020490855c563a2e57a1e55802216ba9f05a312f2a709ee5e9ec5ee36d21aeba292f1414344afb64a6e8c4a4
7
+ data.tar.gz: c3eaf501b6837dffd80b1fd2d2455b66da2571333259c2d16e53e45c5afe7cb6203f60b283372cd20fc53fba6b20e41a05a267bfd6998d11da7f1383799fe85b
@@ -1,10 +1,15 @@
1
1
  require 'ft_gem/shared/ft_shared'
2
2
  require 'ft_gem/view/helpers'
3
+ require 'ft_gem/services/beta_service'
3
4
  module FtGem
4
5
  module Controllers
5
6
  autoload :Helpers, 'ft_gem/controllers/helpers'
6
7
  end
7
8
 
9
+ module Services
10
+ autoload :BetaService, 'ft_gem/services/beta_service'
11
+ end
12
+
8
13
  class Railtie < Rails::Railtie
9
14
  initializer 'ft_gem.view.helpers' do |_app|
10
15
  ActionView::Base.send :include, FtGem::View::Helpers
@@ -8,16 +8,19 @@ 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'])
18
15
 
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)
16
+ return true && whitelisted if FtGem::Services::BetaService.public_beta?(cookie: Base64.decode64(cookies[PUBLICBETA_COOKIE_NAME]),toggles: toggles, index: index)
17
+ return true && whitelisted if FtGem::Services::BetaService.private_beta?(user_id: user_id, toggles: toggles, index: index)
18
+
19
+ update_feature_toggles(toggles: toggles)
20
+ decoded_cookie = Base64.decode64(cookies[TOGGLE_COOKIE_NAME])
21
+
22
+ client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: name)
23
+ toggle_percentage = toggles[index.to_i]['attributes']['percentage']
21
24
 
22
25
  return client_percentage.to_i <= toggle_percentage.to_i && whitelisted
23
26
  rescue StandardError => e
@@ -5,8 +5,9 @@ module FtGem
5
5
  return false unless user_id.present?
6
6
  return false unless toggles.present?
7
7
 
8
- attributes = toggles.dig(index.to_i, 'attributes')
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
 
@@ -14,7 +15,9 @@ module FtGem
14
15
  return false unless toggles.present?
15
16
 
16
17
  attributes = toggles.dig(index.to_i, 'attributes')
17
- cookie == "true" && attributes['status'] == "privatebeta"
18
+
19
+ Rails.logger.info("########### PUBLIC BETA cookie: #{cookie}, status: #{attributes['status']} ################")
20
+ attributes['status'] == "publicbeta" && cookie == "true"
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.10
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Catto