ft_gem 2.0.5 → 2.0.6
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/controllers/helpers.rb +4 -30
- 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: 410802fa5b3402116ecf95b8284291f6b3d5bea88f13b88ad80b29466b788dc7
|
4
|
+
data.tar.gz: c8493473d7f7eb46b7c994594490df08ad57924e3dd67d6139f05f2f41354a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c83817200a8b4b5d8f95bdd6e9eec5a2c1d816d8603ae7871d3f528825eb18d0077b1b807846df658bd924587076ca5ce0b767a68b5926b0d2979e5afe769b7
|
7
|
+
data.tar.gz: 293231e004c84056ac0f7bfd3522220f5943bc4b6a5c6d27ea1f4a1853146bd147a5ce1e030aa7861a0467f2d1d15dc6c46e5c10b10a8962f7e370657614dcf4
|
@@ -5,42 +5,16 @@ module FtGem
|
|
5
5
|
TOGGLE_COOKIE_NAME = 'mnft'.freeze
|
6
6
|
|
7
7
|
def feature_toggle_status(name:)
|
8
|
-
cookies[TOGGLE_COOKIE_NAME] =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
index = toggles.index { |toggle| toggle.include?("#{name} ") }
|
13
|
-
client_percentage = toggles[index].split(' ')[1]
|
14
|
-
toggle_percentage = toggles[index].split(' ')[2]
|
8
|
+
cookies[TOGGLE_COOKIE_NAME] = rand(0..100) if cookies[TOGGLE_COOKIE_NAME].nil? || cookies[TOGGLE_COOKIE_NAME].to_i.zero?
|
9
|
+
data = FtShared.fetch(name: name)
|
10
|
+
toggle_percentage = data['feature_toggle']['toggle_percentage']
|
11
|
+
client_percentage = cookies[TOGGLE_COOKIE_NAME]
|
15
12
|
client_percentage.to_i <= toggle_percentage.to_i
|
16
13
|
rescue StandardError => e
|
17
14
|
Rails.logger.error "FtGem::feature_toggle_status error #{e.backtrace}"
|
18
15
|
false
|
19
16
|
end
|
20
17
|
|
21
|
-
def add_feature_toggle(name:)
|
22
|
-
data = FtShared.fetch(name: name)
|
23
|
-
toggle_percentage = data['feature_toggle']['toggle_percentage']
|
24
|
-
client_percentage = data['feature_toggle']['client_percentage']
|
25
|
-
cookies[TOGGLE_COOKIE_NAME] = "#{cookies[TOGGLE_COOKIE_NAME]}|#{name} #{client_percentage} #{toggle_percentage}"
|
26
|
-
rescue StandardError => e
|
27
|
-
Rails.logger.error "FtGem::add_feature_toggle error #{e.backtrace}"
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
|
31
|
-
def update_feature_toggle(name:)
|
32
|
-
data = FtShared.fetch(name: name)
|
33
|
-
toggle_percentage = data['feature_toggle']['toggle_percentage']
|
34
|
-
toggles = cookies[TOGGLE_COOKIE_NAME].split('|')
|
35
|
-
index = toggles.index { |toggle| toggle.include?("#{name} ") }
|
36
|
-
client_percentage = toggles[index].split(' ')[1]
|
37
|
-
toggles[index] = "#{name} #{client_percentage} #{toggle_percentage}"
|
38
|
-
cookies[TOGGLE_COOKIE_NAME] = toggles.join('|')
|
39
|
-
rescue StandardError => e
|
40
|
-
Rails.logger.error "FTApiGem::update_feature_toggle error #{e.backtrace}"
|
41
|
-
nil
|
42
|
-
end
|
43
|
-
|
44
18
|
def api_feature_toggle_status(name:)
|
45
19
|
toggle = FtShared.fetch(name: name)
|
46
20
|
return false if toggle.nil?
|