ft_gem 3.1.8 → 3.1.10

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: 809676c332224a3afa063feb423dc9e8af915ffe37f8b5315ab45d25102fb903
4
- data.tar.gz: c621a941075cbe797eb6286f5bf26b9d8e7abe8a1efa189369ba8a4c6336c378
3
+ metadata.gz: 21b45e240a1861569b16e5e45a0b1d660511981dec84d6e4c75f2885a1e52225
4
+ data.tar.gz: 2c32bcf43c396dcdf24fb07d982476c0135967a2d19ba8dd9db42bead064c68e
5
5
  SHA512:
6
- metadata.gz: 5ee30a4db3847c8ef0bab9ddde3b547e7f38a9724896bfcd26b05588ddd72a3d94f68e207fcf3e0f6d2e512b7bec0bd3609ed5e84b47342be8eedc0406b9dbb1
7
- data.tar.gz: 62fc8f5afb70f7c1dd15ede41201d75031e2b6f61c8c18906a5a4ee9f1ac3c00080b6d0794ce5f43766aba7e9eda3d6347d11ae11ed262fdb7ed0c914842285a
6
+ metadata.gz: e118c452267dc979e61bf8c1745fc09c83f86e5f295d3fcaf0e4da84e7356d320efdc9497a02675489dc7a0900c26a3e77fd25ee5aca2210c9a60facbd58e2b9
7
+ data.tar.gz: 6e268ed09221c2bd491c5f3fa668cc060661a9557f49f8d234cbb13bf2bf261a9285b76ea85335bac241f6dc6109a81cbaeaf7ed96c4b45e8b68d989c4a0fb8b
@@ -3,6 +3,7 @@ module FtGem
3
3
  module Helpers
4
4
  extend ActiveSupport::Concern
5
5
  TOGGLE_COOKIE_NAME = 'mnft'.freeze
6
+ PUBLICBETA_COOKIE_NAME = 'mnbeta'.freeze
6
7
  require 'base64'
7
8
 
8
9
  def feature_toggle_status(name:, user_id: nil, url: nil)
@@ -14,11 +15,11 @@ module FtGem
14
15
  client_percentage = calc_client_percentage(decoded_cookie: decoded_cookie, toggle_name: name)
15
16
  toggle_percentage = toggles[index.to_i]['attributes']['percentage']
16
17
  whitelisted = FtShared.new.whitelisted?(url: url, whitelist_urls: toggles[index.to_i]['attributes']['whitelist-urls'])
17
- if user_id_beta(user_id: user_id, toggles: toggles, index: index)
18
- return true && whitelisted
19
- else
20
- return client_percentage.to_i <= toggle_percentage.to_i && whitelisted
21
- end
18
+
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)
21
+
22
+ return client_percentage.to_i <= toggle_percentage.to_i && whitelisted
22
23
  rescue StandardError => e
23
24
  Rails.logger.error "FtGem::feature_toggle_status error #{e.backtrace}"
24
25
  false
@@ -53,12 +54,6 @@ module FtGem
53
54
  def api_feature_toggle_status(name:)
54
55
  FtGem::View::Helpers.status(name: name)
55
56
  end
56
-
57
- private
58
-
59
- def user_id_beta(user_id: nil, toggles: nil, index: "")
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
62
57
  end
63
58
  end
64
59
  end
@@ -0,0 +1,21 @@
1
+ module FtGem
2
+ module Services
3
+ module BetaService
4
+ def self.private_beta?(user_id: nil, toggles: nil, index: "")
5
+ return false unless user_id.present?
6
+ return false unless toggles.present?
7
+
8
+ attributes = toggles.dig(index.to_i, 'attributes')
9
+
10
+ attributes['status'] == "privatebeta" && attributes['beta-users'].split(",").include?(user_id.to_s)
11
+ end
12
+
13
+ def self.public_beta?(cookie: "", toggles: nil, index: "")
14
+ return false unless toggles.present?
15
+
16
+ attributes = toggles.dig(index.to_i, 'attributes')
17
+ cookie == "true" && attributes['status'] == "privatebeta"
18
+ end
19
+ end
20
+ end
21
+ 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.8
4
+ version: 3.1.10
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: 2020-11-18 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumsnet_jwt
@@ -38,20 +38,21 @@ 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: []
46
46
  files:
47
47
  - lib/ft_gem.rb
48
48
  - lib/ft_gem/controllers/helpers.rb
49
+ - lib/ft_gem/services/beta_service.rb
49
50
  - lib/ft_gem/shared/ft_shared.rb
50
51
  - lib/ft_gem/view/helpers.rb
51
- homepage:
52
+ homepage:
52
53
  licenses: []
53
54
  metadata: {}
54
- post_install_message:
55
+ post_install_message:
55
56
  rdoc_options: []
56
57
  require_paths:
57
58
  - lib
@@ -66,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 3.0.8
70
- signing_key:
70
+ rubygems_version: 3.0.3
71
+ signing_key:
71
72
  specification_version: 4
72
73
  summary: Client side feature toggle
73
74
  test_files: []