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 +4 -4
- data/lib/ft_gem.rb +5 -0
- data/lib/ft_gem/controllers/helpers.rb +9 -6
- data/lib/ft_gem/services/beta_service.rb +5 -2
- 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: 35400c0fa6a2f7640b62ae165101ed26afac0c10bcacdca9bc4d0adcef9b827b
|
4
|
+
data.tar.gz: c34b83cdd99f07730de5c3942cd6bcbf21ad49b72d48160824ade5f9f6e80880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 545f3a715845a5e452e6340d3d737fe23afb3843020490855c563a2e57a1e55802216ba9f05a312f2a709ee5e9ec5ee36d21aeba292f1414344afb64a6e8c4a4
|
7
|
+
data.tar.gz: c3eaf501b6837dffd80b1fd2d2455b66da2571333259c2d16e53e45c5afe7cb6203f60b283372cd20fc53fba6b20e41a05a267bfd6998d11da7f1383799fe85b
|
data/lib/ft_gem.rb
CHANGED
@@ -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
|
-
|
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(
|
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
|
-
|
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
|