this_feature 0.5.3 → 0.6.0

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: 8d173ac479e6b81bd46368c6d4a16c135781f53c087ecbe787d8b81ab753f9db
4
- data.tar.gz: ad26a2049348ae2ef9ebe0d60a4a3d1059b0cb2a38db10b25c2707a33b5c8bab
3
+ metadata.gz: 969159045580ea9f6117ccef0054dc95c9cd2e2d93e96d607cff03721ee017ea
4
+ data.tar.gz: 912ad44c5f32cdf932cae4b914fed37df1ae6f496c557f03594a15b7b77b74ac
5
5
  SHA512:
6
- metadata.gz: c9b4b5144aeba8d98fd881efa6b99ab68a4ea3cc44571d4757b0f9182a1b95f7f947b95926a8f5954297139260098c524c7cbdab94f49228b3436ae7ff71a0b6
7
- data.tar.gz: 9b840f3f2b75a0ef67a4e05a426f4faf73792faabd55df3a423f935a1a60d93b638c0d7474af56b7a4640292f84986e8bbeb424abb4e5bb96e59523a941f544f
6
+ metadata.gz: e3541f52fd4314a25583f611b6cd33be4e6d9fd4e948e8dc0c0fc4158f8355a0d712bf8c5d4c6e840e6e53ffa904a4d0feb6f54e56d26546c26a9dcf2f77e1ef
7
+ data.tar.gz: d1b0ad6542b7971cfaae7b56047df473fa0ea5ece1793fa15f132f8a582e0b1b1d59ffe9949b213c5a8b8dd6a870f0e8f2c0e005c954c74ac5121366e209aee7
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- this_feature (0.5.3)
5
- this_feature-adapters-flipper (0.5.3)
4
+ this_feature (0.6.0)
5
+ this_feature-adapters-flipper (0.6.0)
6
6
  flipper (~> 0.16)
7
7
  flipper-active_record (~> 0.16)
8
8
  this_feature
9
- this_feature-adapters-split_io (0.5.3)
9
+ this_feature-adapters-split_io (0.6.0)
10
10
  splitclient-rb
11
11
  this_feature
12
12
 
@@ -33,23 +33,26 @@ GEM
33
33
  activerecord
34
34
  database_cleaner (~> 1.8.0)
35
35
  diff-lcs (1.3)
36
- faraday (1.0.1)
36
+ faraday (1.3.0)
37
+ faraday-net_http (~> 1.0)
37
38
  multipart-post (>= 1.2, < 3)
38
- flipper (0.19.0)
39
- flipper-active_record (0.19.0)
39
+ ruby2_keywords
40
+ faraday-net_http (1.0.1)
41
+ flipper (0.20.3)
42
+ flipper-active_record (0.20.3)
40
43
  activerecord (>= 5.0, < 7)
41
- flipper (~> 0.19.0)
42
- gem-release (2.1.1)
44
+ flipper (~> 0.20.3)
45
+ gem-release (2.2.1)
43
46
  hitimes (1.3.1)
44
47
  i18n (1.8.5)
45
48
  concurrent-ruby (~> 1.0)
46
- json (2.3.1)
49
+ json (2.5.1)
47
50
  jwt (2.2.2)
48
51
  lru_redux (1.1.0)
49
52
  method_source (1.0.0)
50
53
  minitest (5.14.1)
51
54
  multipart-post (2.1.1)
52
- net-http-persistent (4.0.0)
55
+ net-http-persistent (4.0.1)
53
56
  connection_pool (~> 2.2)
54
57
  pry (0.13.1)
55
58
  coderay (~> 1.1)
@@ -58,7 +61,7 @@ GEM
58
61
  byebug (~> 11.0)
59
62
  pry (~> 0.13.0)
60
63
  rake (13.0.1)
61
- redis (4.2.2)
64
+ redis (4.2.5)
62
65
  rspec (3.9.0)
63
66
  rspec-core (~> 3.9.0)
64
67
  rspec-expectations (~> 3.9.0)
@@ -72,16 +75,17 @@ GEM
72
75
  diff-lcs (>= 1.2.0, < 2.0)
73
76
  rspec-support (~> 3.9.0)
74
77
  rspec-support (3.9.2)
78
+ ruby2_keywords (0.0.4)
75
79
  socketry (0.5.1)
76
80
  hitimes (~> 1.2)
77
- splitclient-rb (7.1.3)
81
+ splitclient-rb (7.2.2)
78
82
  concurrent-ruby (~> 1.0)
79
83
  faraday (>= 0.8)
80
84
  json (>= 1.8)
81
85
  jwt (>= 2.2.1)
82
86
  lru_redux
83
87
  net-http-persistent (>= 2.9)
84
- redis (>= 3.2)
88
+ redis (>= 4.2.2)
85
89
  socketry (~> 0.5.1)
86
90
  thread_safe (>= 0.3)
87
91
  sqlite3 (1.4.2)
@@ -6,8 +6,9 @@ class ThisFeature
6
6
  # used as treatment key when none is given, it's required by split
7
7
  UNDEFINED_KEY = 'undefined_key'
8
8
 
9
- def initialize(client: nil)
9
+ def initialize(client: nil, context_key_method: nil)
10
10
  @client = client || default_split_client
11
+ @context_key_method = context_key_method
11
12
 
12
13
  @client.block_until_ready
13
14
  end
@@ -30,18 +31,18 @@ class ThisFeature
30
31
 
31
32
  private
32
33
 
33
- attr_reader :client
34
+ attr_reader :client, :context_key_method
34
35
 
35
36
  def treatment(flag_name, context: UNDEFINED_KEY, data: {})
36
- key = if context.nil?
37
- UNDEFINED_KEY
38
- elsif context.respond_to?(:to_s)
39
- context.to_s
40
- else
41
- context
42
- end
43
-
44
- client.get_treatment(key, flag_name, data)
37
+ client.get_treatment(context_key(context), flag_name, data)
38
+ end
39
+
40
+ def context_key(context)
41
+ return UNDEFINED_KEY if context.nil? || context.eql?(UNDEFINED_KEY)
42
+ return context.send(context_key_method) unless context_key_method.nil?
43
+ return context.to_s if context.respond_to?(:to_s)
44
+
45
+ context
45
46
  end
46
47
 
47
48
  def default_split_client
@@ -1,3 +1,3 @@
1
1
  class ThisFeature
2
- VERSION = "0.5.3"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: this_feature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Pleaner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-30 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,7 +150,7 @@ licenses: []
150
150
  metadata:
151
151
  homepage_uri: https://github.com/hoverinc/this_feature
152
152
  source_code_uri: https://github.com/hoverinc/this_feature
153
- post_install_message:
153
+ post_install_message:
154
154
  rdoc_options: []
155
155
  require_paths:
156
156
  - lib
@@ -165,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  requirements: []
168
- rubygems_version: 3.0.3
169
- signing_key:
168
+ rubygems_version: 3.1.2
169
+ signing_key:
170
170
  specification_version: 4
171
171
  summary: Feature flag control
172
172
  test_files: []