ft_gem 3.1.2 → 3.1.7

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: 2d19039825e1e26531c6abefaefc2e368679d26dcfc87f7172c4b0780a3eda49
4
- data.tar.gz: abe53272347dd4e2e3d820fdcd321f8e9d166a62b47bb875bb2e6a62c515ea4f
3
+ metadata.gz: 871c3d6f5f3d0f85c5d1677cd6f72c41590c2d2cb03dd09a8bb97476831e9fb2
4
+ data.tar.gz: f96b70b64a0385f08580ee9c676b31122e4be4336532c3e376bfa69135cb725c
5
5
  SHA512:
6
- metadata.gz: a2a093c4a64b3725248f3abc40f367ea9c84ea40caefb8da77cf414c5d96136f33a468af8bc7d603e0ad2e18a4cf55e80e0f35a0e14a9b316b4f57d971e3f959
7
- data.tar.gz: 3a5f60221a4f0f61032dd7dfdb232f324f285c3f318f25593564d9262fbfccb6ddae27b0de7ed186a104b08316824315b5f9dcb2b4bc2027e2b6bfb399d5565e
6
+ metadata.gz: c656b69d716010847867e54d1c5fb18a904051421b2214a532a77bc3a7a46bfff39d08c8cc21b281cc76950b4b7183ba4c68c12fd135067bb0b553a52740bdb5
7
+ data.tar.gz: 0e81709647e1b7306d0e6049556f57b5e96f15af9419b7b5c0e502ead9ad82f7c04e2fc216a684d6801486c428c489cf28248b12b7e38788d9dae97b74fda2b8
@@ -5,7 +5,7 @@ module FtGem
5
5
  TOGGLE_COOKIE_NAME = 'mnft'.freeze
6
6
  require 'base64'
7
7
 
8
- def feature_toggle_status(name:, url: nil)
8
+ def feature_toggle_status(name:, user_id: nil, url: nil)
9
9
  toggles = FtShared.new.all_toggles
10
10
  update_feature_toggles(toggles: toggles)
11
11
  decoded_cookie = Base64.decode64(cookies[TOGGLE_COOKIE_NAME])
@@ -14,7 +14,11 @@ module FtGem
14
14
  client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: name)
15
15
  toggle_percentage = toggles[index.to_i]['attributes']['percentage']
16
16
  whitelisted = FtShared.new.whitelisted?(url: url, whitelist_urls: toggles[index.to_i]['attributes']['whitelist-urls'])
17
- client_percentage.to_i <= toggle_percentage.to_i && whitelisted
17
+ if user_id_beta(user_id: user_id, toggles: toggles)
18
+ return true && whitelisted
19
+ else
20
+ return client_percentage.to_i <= toggle_percentage.to_i && whitelisted
21
+ end
18
22
  rescue StandardError => e
19
23
  Rails.logger.error "FtGem::feature_toggle_status error #{e.backtrace}"
20
24
  false
@@ -29,7 +33,7 @@ module FtGem
29
33
  new_cookie.push("#{toggle['attributes']['name']}:#{client_percentage}")
30
34
  end
31
35
  cookies.delete TOGGLE_COOKIE_NAME, domain: ENV['COOKIE_DOMAIN']
32
- cookies[TOGGLE_COOKIE_NAME] = { value: Base64.encode64(new_cookie.join(',')).to_s, secure: true }
36
+ cookies[TOGGLE_COOKIE_NAME] = { value: Base64.strict_encode64(new_cookie.join(',')).to_s, secure: true }
33
37
  rescue StandardError => e
34
38
  Rails.logger.error "FTApiGem::update_feature_toggles error #{e.backtrace}"
35
39
  nil
@@ -49,6 +53,12 @@ module FtGem
49
53
  def api_feature_toggle_status(name:)
50
54
  FtGem::View::Helpers.status(name: name)
51
55
  end
56
+
57
+ private
58
+
59
+ def user_id_beta(user_id: nil, toggles: nil)
60
+ user_id.present? && toggles.present? && toggles[index.to_i]['attributes']['status'] == "amber" && toggles[index.to_i]['attributes']['beta-users'].split(",").include?(user_id.to_s)
61
+ end
52
62
  end
53
63
  end
54
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ft_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Catto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-09 00:00:00.000000000 Z
11
+ date: 2020-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumsnet_jwt
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description:
42
- email:
41
+ description:
42
+ email:
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
@@ -48,10 +48,10 @@ files:
48
48
  - lib/ft_gem/controllers/helpers.rb
49
49
  - lib/ft_gem/shared/ft_shared.rb
50
50
  - lib/ft_gem/view/helpers.rb
51
- homepage:
51
+ homepage:
52
52
  licenses: []
53
53
  metadata: {}
54
- post_install_message:
54
+ post_install_message:
55
55
  rdoc_options: []
56
56
  require_paths:
57
57
  - lib
@@ -66,9 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubyforge_project:
70
- rubygems_version: 2.7.8
71
- signing_key:
69
+ rubygems_version: 3.0.8
70
+ signing_key:
72
71
  specification_version: 4
73
72
  summary: Client side feature toggle
74
73
  test_files: []