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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6426aadf7c5b924f6fd904c64fa981950a407e1e92925eae602305951ebcc86
4
- data.tar.gz: 589e9121af637700446a2e31eb144bc35ca2f55aaadadcea1b2331380b415258
3
+ metadata.gz: 410802fa5b3402116ecf95b8284291f6b3d5bea88f13b88ad80b29466b788dc7
4
+ data.tar.gz: c8493473d7f7eb46b7c994594490df08ad57924e3dd67d6139f05f2f41354a1e
5
5
  SHA512:
6
- metadata.gz: 2ea024433f08e5387bf79396e416e3977baa0d0ed1578bc43fd7b3b1726c7b97854f7180d5fb9fc862fc46c8616d2b5280ad16d8a76189ebfb2bac4e1604a0ac
7
- data.tar.gz: c547088dfe590a6e5fc8c1ba6d36d77c29b5af61e76fbab31958a6fef8d24e7035fdef419c82cf40e83f730c53cbf933f10915145005338aac9dd06a480d9fd9
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] = '' if cookies[TOGGLE_COOKIE_NAME].nil?
9
- add_feature_toggle(name: name) unless cookies[TOGGLE_COOKIE_NAME].include?("#{name} ")
10
- update_feature_toggle(name: name) if cookies[TOGGLE_COOKIE_NAME].include?("#{name} ")
11
- toggles = cookies[TOGGLE_COOKIE_NAME].split('|')
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?
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: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Catto