determinator 2.5.4 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +33 -0
- data/CHANGELOG.md +22 -0
- data/README.md +17 -0
- data/determinator.gemspec +4 -4
- data/examples/determinator-rails/Gemfile +1 -2
- data/examples/determinator-rails/Gemfile.lock +93 -89
- data/examples/determinator-rails/app/controllers/index_controller.rb +6 -2
- data/examples/determinator-rails/config/initializers/determinator.rb +4 -2
- data/examples/determinator-rails/config/initializers/new_framework_defaults.rb +0 -1
- data/examples/determinator-rails/example_features/colloquial_welcome +14 -0
- data/examples/determinator-rails/example_features/welcome_emoji +19 -0
- data/lib/determinator/control.rb +3 -4
- data/lib/determinator/feature.rb +2 -8
- data/lib/determinator/retrieve/http_retriever.rb +25 -0
- data/lib/determinator/version.rb +1 -1
- data/lib/determinator.rb +3 -3
- data/lib/rspec/determinator.rb +5 -2
- metadata +13 -11
- data/examples/determinator-rails/.env +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dcdd00664fa1b47134a36911b0d0319c98d8fdb3c012b54342f97a160f63424
|
4
|
+
data.tar.gz: b85ac99ae90d9e5b5fd009227f2f07f39dea8ce8a3ba6854cb7cd524850c785a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 845d3d1f0b96da3835a3ca7aec37dbdbaeac4a10d574277111f1642ccb55ff4b86abd420363a943f430efad68071bc34720d9fd03ba35cbcd12fd62332cb392b
|
7
|
+
data.tar.gz: bf1f7889514902a82c72db708d030e789228abbc5237c94c3869d19bf5cee8a8888527d49f220c3f2d0afc12ce8d726dfaf9f00070f4bbc64c080bc79d155fd6
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set git user
|
15
|
+
run: |
|
16
|
+
git config user.email "rooci@deliveroo.co.uk"
|
17
|
+
git config user.name "Determinator Release Github Action"
|
18
|
+
- name: Set up Ruby 2.6
|
19
|
+
uses: actions/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: 2.6.x
|
22
|
+
|
23
|
+
- name: Publish to RubyGems
|
24
|
+
run: |
|
25
|
+
mkdir -p $HOME/.gem
|
26
|
+
touch $HOME/.gem/credentials
|
27
|
+
chmod 0600 $HOME/.gem/credentials
|
28
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
29
|
+
gem install bundler
|
30
|
+
bundle install --jobs 4 --retry 3
|
31
|
+
rake release
|
32
|
+
env:
|
33
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# 2.8.0
|
2
|
+
|
3
|
+
Feature:
|
4
|
+
- When a GUID bucketed feature is misconfigured, handle the error and return false.
|
5
|
+
|
6
|
+
# 2.7.1
|
7
|
+
|
8
|
+
Feature:
|
9
|
+
- Add `before_retrieve` and `after_retrieve` hooks for `Determinator::Retrieve::HttpRetriever`
|
10
|
+
|
11
|
+
# 2.7.0
|
12
|
+
|
13
|
+
⚠️ This release includes breaking changes ⚠️
|
14
|
+
|
15
|
+
Interface change:
|
16
|
+
- Constraints which are not arrays of strings are no longer accepted; if present, the library returns false and logs an error.
|
17
|
+
|
18
|
+
# 2.6.0
|
19
|
+
|
20
|
+
Interface change:
|
21
|
+
- A `feature_cache` is now required to use Determinator. See the `examples/determinator-rails/config/initializers/determinator.rb` for a quick start.
|
22
|
+
|
1
23
|
# 2.5.4
|
2
24
|
|
3
25
|
Bug fix:
|
data/README.md
CHANGED
@@ -156,6 +156,23 @@ or in instances where the event bus provides a full feature object with a name i
|
|
156
156
|
|
157
157
|
This will expire both the limited local cache and the larger shared cache.
|
158
158
|
|
159
|
+
### Using hooks for retriever
|
160
|
+
|
161
|
+
```HttpRetriever``` has ```before_retrieve``` and ```after_retrieve``` hooks.
|
162
|
+
|
163
|
+
Example of usage:
|
164
|
+
```ruby
|
165
|
+
http_retriever = Determinator::Retrieve::HttpRetriever.new(faraday_connection)
|
166
|
+
|
167
|
+
http_retriever.before_retrieve do
|
168
|
+
do_something
|
169
|
+
end
|
170
|
+
|
171
|
+
http_retriever.after_retrieve do |status, err|
|
172
|
+
raise err if err
|
173
|
+
do_something(status)
|
174
|
+
end
|
175
|
+
```
|
159
176
|
## Further Usage
|
160
177
|
|
161
178
|
Once this is done you can ask for a determination like this:
|
data/determinator.gemspec
CHANGED
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency "faraday"
|
24
24
|
spec.add_runtime_dependency "semantic", "~> 1.6"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler"
|
27
|
-
spec.add_development_dependency "rake", "~>
|
26
|
+
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
spec.add_development_dependency "rspec-its", "~> 1.2"
|
30
30
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
31
|
-
spec.add_development_dependency "
|
31
|
+
spec.add_development_dependency "factory_bot", "~> 4.8"
|
32
32
|
spec.add_development_dependency 'webmock'
|
33
|
-
spec.add_development_dependency
|
33
|
+
spec.add_development_dependency 'sidekiq'
|
34
34
|
end
|
@@ -1,140 +1,144 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
determinator (
|
4
|
+
determinator (2.6.0)
|
5
5
|
faraday
|
6
|
+
semantic (~> 1.6)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
actioncable (5.
|
11
|
-
actionpack (= 5.
|
12
|
-
nio4r (
|
13
|
-
websocket-driver (
|
14
|
-
actionmailer (5.
|
15
|
-
actionpack (= 5.
|
16
|
-
actionview (= 5.
|
17
|
-
activejob (= 5.
|
11
|
+
actioncable (5.2.4.4)
|
12
|
+
actionpack (= 5.2.4.4)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailer (5.2.4.4)
|
16
|
+
actionpack (= 5.2.4.4)
|
17
|
+
actionview (= 5.2.4.4)
|
18
|
+
activejob (= 5.2.4.4)
|
18
19
|
mail (~> 2.5, >= 2.5.4)
|
19
20
|
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.
|
21
|
-
actionview (= 5.
|
22
|
-
activesupport (= 5.
|
23
|
-
rack (~> 2.0)
|
24
|
-
rack-test (
|
21
|
+
actionpack (5.2.4.4)
|
22
|
+
actionview (= 5.2.4.4)
|
23
|
+
activesupport (= 5.2.4.4)
|
24
|
+
rack (~> 2.0, >= 2.0.8)
|
25
|
+
rack-test (>= 0.6.3)
|
25
26
|
rails-dom-testing (~> 2.0)
|
26
27
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.
|
28
|
-
activesupport (= 5.
|
28
|
+
actionview (5.2.4.4)
|
29
|
+
activesupport (= 5.2.4.4)
|
29
30
|
builder (~> 3.1)
|
30
|
-
|
31
|
+
erubi (~> 1.4)
|
31
32
|
rails-dom-testing (~> 2.0)
|
32
33
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.
|
34
|
-
activesupport (= 5.
|
34
|
+
activejob (5.2.4.4)
|
35
|
+
activesupport (= 5.2.4.4)
|
35
36
|
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.
|
37
|
-
activesupport (= 5.
|
38
|
-
activerecord (5.
|
39
|
-
activemodel (= 5.
|
40
|
-
activesupport (= 5.
|
41
|
-
arel (
|
42
|
-
|
37
|
+
activemodel (5.2.4.4)
|
38
|
+
activesupport (= 5.2.4.4)
|
39
|
+
activerecord (5.2.4.4)
|
40
|
+
activemodel (= 5.2.4.4)
|
41
|
+
activesupport (= 5.2.4.4)
|
42
|
+
arel (>= 9.0)
|
43
|
+
activestorage (5.2.4.4)
|
44
|
+
actionpack (= 5.2.4.4)
|
45
|
+
activerecord (= 5.2.4.4)
|
46
|
+
marcel (~> 0.3.1)
|
47
|
+
activesupport (5.2.4.4)
|
43
48
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
44
49
|
i18n (>= 0.7, < 2)
|
45
50
|
minitest (~> 5.1)
|
46
51
|
tzinfo (~> 1.1)
|
47
|
-
arel (
|
48
|
-
builder (3.2.
|
49
|
-
byebug (
|
50
|
-
concurrent-ruby (1.
|
51
|
-
|
52
|
-
|
53
|
-
dotenv (2.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
arel (9.0.0)
|
53
|
+
builder (3.2.4)
|
54
|
+
byebug (11.1.3)
|
55
|
+
concurrent-ruby (1.1.8)
|
56
|
+
crass (1.0.6)
|
57
|
+
dotenv (2.7.6)
|
58
|
+
dotenv-rails (2.7.6)
|
59
|
+
dotenv (= 2.7.6)
|
60
|
+
railties (>= 3.2)
|
61
|
+
erubi (1.10.0)
|
62
|
+
faraday (1.3.0)
|
63
|
+
faraday-net_http (~> 1.0)
|
59
64
|
multipart-post (>= 1.2, < 3)
|
60
|
-
|
65
|
+
ruby2_keywords
|
66
|
+
faraday-net_http (1.0.1)
|
67
|
+
globalid (0.4.2)
|
61
68
|
activesupport (>= 4.2.0)
|
62
|
-
i18n (1.
|
69
|
+
i18n (1.8.7)
|
63
70
|
concurrent-ruby (~> 1.0)
|
64
|
-
loofah (2.
|
71
|
+
loofah (2.9.0)
|
65
72
|
crass (~> 1.0.2)
|
66
73
|
nokogiri (>= 1.5.9)
|
67
|
-
mail (2.7.
|
74
|
+
mail (2.7.1)
|
68
75
|
mini_mime (>= 0.1.1)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
rack
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
76
|
+
marcel (0.3.3)
|
77
|
+
mimemagic (~> 0.3.2)
|
78
|
+
method_source (1.0.0)
|
79
|
+
mimemagic (0.3.5)
|
80
|
+
mini_mime (1.0.2)
|
81
|
+
minitest (5.14.3)
|
82
|
+
multipart-post (2.1.1)
|
83
|
+
nio4r (2.5.4)
|
84
|
+
nokogiri (1.11.1-x86_64-darwin)
|
85
|
+
racc (~> 1.4)
|
86
|
+
puma (3.12.6)
|
87
|
+
racc (1.5.2)
|
88
|
+
rack (2.2.3)
|
89
|
+
rack-test (1.1.0)
|
90
|
+
rack (>= 1.0, < 3)
|
91
|
+
rails (5.2.4.4)
|
92
|
+
actioncable (= 5.2.4.4)
|
93
|
+
actionmailer (= 5.2.4.4)
|
94
|
+
actionpack (= 5.2.4.4)
|
95
|
+
actionview (= 5.2.4.4)
|
96
|
+
activejob (= 5.2.4.4)
|
97
|
+
activemodel (= 5.2.4.4)
|
98
|
+
activerecord (= 5.2.4.4)
|
99
|
+
activestorage (= 5.2.4.4)
|
100
|
+
activesupport (= 5.2.4.4)
|
92
101
|
bundler (>= 1.3.0)
|
93
|
-
railties (= 5.
|
102
|
+
railties (= 5.2.4.4)
|
94
103
|
sprockets-rails (>= 2.0.0)
|
95
104
|
rails-dom-testing (2.0.3)
|
96
105
|
activesupport (>= 4.2.0)
|
97
106
|
nokogiri (>= 1.6)
|
98
|
-
rails-html-sanitizer (1.0
|
99
|
-
loofah (~> 2.
|
100
|
-
railties (5.
|
101
|
-
actionpack (= 5.
|
102
|
-
activesupport (= 5.
|
107
|
+
rails-html-sanitizer (1.3.0)
|
108
|
+
loofah (~> 2.3)
|
109
|
+
railties (5.2.4.4)
|
110
|
+
actionpack (= 5.2.4.4)
|
111
|
+
activesupport (= 5.2.4.4)
|
103
112
|
method_source
|
104
113
|
rake (>= 0.8.7)
|
105
|
-
thor (>= 0.
|
106
|
-
rake (
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
connection_pool (~> 2.2, >= 2.2.0)
|
111
|
-
rack-protection (>= 1.5.0)
|
112
|
-
redis (>= 3.3.5, < 5)
|
113
|
-
sprockets (3.7.1)
|
114
|
+
thor (>= 0.19.0, < 2.0)
|
115
|
+
rake (13.0.3)
|
116
|
+
ruby2_keywords (0.0.4)
|
117
|
+
semantic (1.6.1)
|
118
|
+
sprockets (4.0.2)
|
114
119
|
concurrent-ruby (~> 1.0)
|
115
120
|
rack (> 1, < 3)
|
116
|
-
sprockets-rails (3.2.
|
121
|
+
sprockets-rails (3.2.2)
|
117
122
|
actionpack (>= 4.0)
|
118
123
|
activesupport (>= 4.0)
|
119
124
|
sprockets (>= 3.0.0)
|
120
|
-
thor (
|
125
|
+
thor (1.1.0)
|
121
126
|
thread_safe (0.3.6)
|
122
|
-
tzinfo (1.2.
|
127
|
+
tzinfo (1.2.9)
|
123
128
|
thread_safe (~> 0.1)
|
124
|
-
websocket-driver (0.
|
129
|
+
websocket-driver (0.7.3)
|
125
130
|
websocket-extensions (>= 0.1.0)
|
126
|
-
websocket-extensions (0.1.
|
131
|
+
websocket-extensions (0.1.5)
|
127
132
|
|
128
133
|
PLATFORMS
|
129
|
-
|
134
|
+
x86_64-darwin-19
|
130
135
|
|
131
136
|
DEPENDENCIES
|
132
137
|
byebug
|
133
138
|
determinator!
|
134
139
|
dotenv-rails
|
135
140
|
puma (~> 3.0)
|
136
|
-
rails (~> 5.
|
137
|
-
sidekiq
|
141
|
+
rails (~> 5.1)
|
138
142
|
|
139
143
|
BUNDLED WITH
|
140
|
-
|
144
|
+
2.2.7
|
@@ -5,9 +5,13 @@ class IndexController < ApplicationController
|
|
5
5
|
|
6
6
|
message = [
|
7
7
|
is_colloquial ? "hi world" : "hello world",
|
8
|
-
emoji
|
8
|
+
(emoji if emoji)
|
9
9
|
].compact.join(" ")
|
10
10
|
|
11
|
-
|
11
|
+
explain = "An experiment and a feature flag are being checked for the user with guid #{guid}. "
|
12
|
+
explain += "The feature flag (colloquial_welcome) is #{is_colloquial ? 'on' : 'off'}. "
|
13
|
+
explain += "The experiment (welcome_emoji) returned #{emoji}#{", so is omitted" unless emoji}."
|
14
|
+
|
15
|
+
render json: { welcome: message, explanation: explain }
|
12
16
|
end
|
13
17
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require 'determinator/retrieve/
|
1
|
+
require 'determinator/retrieve/file'
|
2
2
|
require 'active_support/cache'
|
3
3
|
|
4
|
-
|
4
|
+
# File retriever just for example; use a Dynaconf retriever in your app
|
5
|
+
# retrieval = Determinator::Retrieve::Dynaconf.new(base_url: ENV['DYNACONF_URL'], service_name: 'determinator-rails')
|
6
|
+
retrieval = Determinator::Retrieve::File.new(root: File.join(__dir__, "../../example_features"))
|
5
7
|
feature_cache = Determinator::Cache::FetchWrapper.new(
|
6
8
|
ActiveSupport::Cache::MemoryStore.new(expires_in: 1.minute)
|
7
9
|
)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"id": "colloquial_welcome",
|
3
|
+
"identifier": "colloquial_welcome",
|
4
|
+
"name": "Whether a colloquial welcome should be used",
|
5
|
+
"active": true,
|
6
|
+
"bucket_type": "guid",
|
7
|
+
"target_groups": [
|
8
|
+
{
|
9
|
+
"name": "50% of users",
|
10
|
+
"rollout": 32768,
|
11
|
+
"constraints": {}
|
12
|
+
}
|
13
|
+
]
|
14
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"id": "welcome_emoji",
|
3
|
+
"identifier": "welcome_emoji",
|
4
|
+
"name": "What emoji should be used for the example hello",
|
5
|
+
"active": true,
|
6
|
+
"bucket_type": "guid",
|
7
|
+
"variants": {
|
8
|
+
"👋": 1,
|
9
|
+
"🎉": 1
|
10
|
+
},
|
11
|
+
"winning_variant": null,
|
12
|
+
"target_groups": [
|
13
|
+
{
|
14
|
+
"name": "50% of users",
|
15
|
+
"rollout": 32768,
|
16
|
+
"constraints": {}
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
data/lib/determinator/control.rb
CHANGED
@@ -124,13 +124,9 @@ module Determinator
|
|
124
124
|
# require_variant_determination?
|
125
125
|
return true unless require_variant_determination?(feature)
|
126
126
|
|
127
|
-
|
128
|
-
|
129
127
|
explainer.log(:chosen_variant) {
|
130
128
|
variant_for(feature, indicators.variant)
|
131
129
|
}
|
132
|
-
rescue ArgumentError
|
133
|
-
raise
|
134
130
|
|
135
131
|
rescue => e
|
136
132
|
Determinator.notice_error(e)
|
@@ -219,6 +215,9 @@ module Determinator
|
|
219
215
|
end
|
220
216
|
|
221
217
|
def matches_constraints(normalised_properties, constraints)
|
218
|
+
unless constraints.all?{ |k, v| k.is_a?(String) && v.all?{ |vv| vv.is_a?(String) } }
|
219
|
+
raise "Constraints must by arrays of strings"
|
220
|
+
end
|
222
221
|
constraints.reduce(true) do |fit, (scope, *required)|
|
223
222
|
present = [*normalised_properties[scope]]
|
224
223
|
fit && matches_requirements?(scope, required, present)
|
data/lib/determinator/feature.rb
CHANGED
@@ -84,7 +84,7 @@ module Determinator
|
|
84
84
|
TargetGroup.new(
|
85
85
|
name: target_group['name'],
|
86
86
|
rollout: target_group['rollout'].to_i,
|
87
|
-
constraints:
|
87
|
+
constraints: constraints
|
88
88
|
)
|
89
89
|
|
90
90
|
# Invalid target groups are ignored
|
@@ -111,17 +111,11 @@ module Determinator
|
|
111
111
|
name: fixed_determination['name'],
|
112
112
|
feature_on: fixed_determination['feature_on'],
|
113
113
|
variant: variant,
|
114
|
-
constraints:
|
114
|
+
constraints: constraints
|
115
115
|
)
|
116
116
|
# Invalid fixed determinations are ignored
|
117
117
|
rescue
|
118
118
|
nil
|
119
119
|
end
|
120
|
-
|
121
|
-
def parse_constraints(constraints)
|
122
|
-
constraints.each_with_object({}) do |(key, value), hash|
|
123
|
-
hash[key.to_s] = [*value].map(&:to_s)
|
124
|
-
end
|
125
|
-
end
|
126
120
|
end
|
127
121
|
end
|
@@ -10,11 +10,14 @@ module Determinator
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def retrieve(name)
|
13
|
+
before_hook
|
13
14
|
response = @connection.get("/features/#{name}")
|
15
|
+
after_hook(response.status)
|
14
16
|
return Determinator::Serializers::JSON.load(response.body) if response.status == 200
|
15
17
|
return MissingResponse.new if response.status == 404
|
16
18
|
rescue => e
|
17
19
|
Determinator.notice_error(e)
|
20
|
+
after_hook(500, e)
|
18
21
|
ErrorResponse.new
|
19
22
|
end
|
20
23
|
|
@@ -29,6 +32,28 @@ module Determinator
|
|
29
32
|
def get_name(url)
|
30
33
|
(url.match('features\/(.*)\z') || [])[1]
|
31
34
|
end
|
35
|
+
|
36
|
+
def before_retrieve(&block)
|
37
|
+
@before_retrieve = block
|
38
|
+
end
|
39
|
+
|
40
|
+
def after_retrieve(&block)
|
41
|
+
@after_retrieve = block
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def after_hook(status, error = nil)
|
47
|
+
return unless @after_retrieve
|
48
|
+
|
49
|
+
@after_retrieve.call(status, error)
|
50
|
+
end
|
51
|
+
|
52
|
+
def before_hook
|
53
|
+
return unless @before_retrieve
|
54
|
+
|
55
|
+
@before_retrieve.call
|
56
|
+
end
|
32
57
|
end
|
33
58
|
end
|
34
59
|
end
|
data/lib/determinator/version.rb
CHANGED
data/lib/determinator.rb
CHANGED
@@ -15,13 +15,13 @@ module Determinator
|
|
15
15
|
class << self
|
16
16
|
attr_reader :feature_cache, :retrieval
|
17
17
|
# @param :retrieval [Determinator::Retrieve::Routemaster] A retrieval instance for Features
|
18
|
+
# @param :feature_cache [#call] a caching proc, accepting a feature name, which will return the named feature or yield (and store) if not available
|
18
19
|
# @param :errors [#call, nil] a proc, accepting an error, which will be called with any errors which occur while determinating
|
19
20
|
# @param :missing_feature [#call, nil] a proc, accepting a feature name, which will be called any time a feature is requested but isn't available
|
20
|
-
|
21
|
-
def configure(retrieval:, errors: nil, missing_feature: nil, feature_cache: nil)
|
21
|
+
def configure(retrieval:, feature_cache:, errors: nil, missing_feature: nil)
|
22
22
|
self.on_error(&errors) if errors
|
23
23
|
self.on_missing_feature(&missing_feature) if missing_feature
|
24
|
-
@feature_cache = feature_cache
|
24
|
+
@feature_cache = feature_cache
|
25
25
|
@retrieval = retrieval
|
26
26
|
@instance = Control.new(retrieval: retrieval)
|
27
27
|
end
|
data/lib/rspec/determinator.rb
CHANGED
@@ -3,6 +3,9 @@ require_relative '../determinator/retrieve/in_memory_retriever'
|
|
3
3
|
|
4
4
|
module RSpec
|
5
5
|
module Determinator
|
6
|
+
|
7
|
+
DO_NOT_USE_IN_PRODUCTION_CODE_NULL_FEATURE_CACHE = -> (name, &block) { block.call(name) }
|
8
|
+
|
6
9
|
def self.included(by)
|
7
10
|
by.extend(DSL)
|
8
11
|
|
@@ -12,10 +15,10 @@ module RSpec
|
|
12
15
|
old_retriever = ::Determinator.instance.retrieval
|
13
16
|
begin
|
14
17
|
fake_retriever.clear!
|
15
|
-
::Determinator.configure(retrieval: fake_retriever)
|
18
|
+
::Determinator.configure(retrieval: fake_retriever, feature_cache: DO_NOT_USE_IN_PRODUCTION_CODE_NULL_FEATURE_CACHE)
|
16
19
|
example.run
|
17
20
|
ensure
|
18
|
-
::Determinator.configure(retrieval: old_retriever)
|
21
|
+
::Determinator.configure(retrieval: old_retriever, feature_cache: DO_NOT_USE_IN_PRODUCTION_CODE_NULL_FEATURE_CACHE)
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: determinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Hastings-Spital
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -42,30 +42,30 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '12.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '12.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '4.7'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: factory_bot
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
@@ -159,6 +159,7 @@ extra_rdoc_files: []
|
|
159
159
|
files:
|
160
160
|
- ".circleci/config.yml"
|
161
161
|
- ".circleci/config.yml.erb"
|
162
|
+
- ".github/workflows/gem-push.yml"
|
162
163
|
- ".gitignore"
|
163
164
|
- ".gitmodules"
|
164
165
|
- ".rspec"
|
@@ -175,7 +176,6 @@ files:
|
|
175
176
|
- docs/background.md
|
176
177
|
- docs/img/determinator.jpg
|
177
178
|
- docs/local_development.md
|
178
|
-
- examples/determinator-rails/.env
|
179
179
|
- examples/determinator-rails/.gitignore
|
180
180
|
- examples/determinator-rails/Gemfile
|
181
181
|
- examples/determinator-rails/Gemfile.lock
|
@@ -202,6 +202,8 @@ files:
|
|
202
202
|
- examples/determinator-rails/config/puma.rb
|
203
203
|
- examples/determinator-rails/config/routes.rb
|
204
204
|
- examples/determinator-rails/config/secrets.yml
|
205
|
+
- examples/determinator-rails/example_features/colloquial_welcome
|
206
|
+
- examples/determinator-rails/example_features/welcome_emoji
|
205
207
|
- examples/determinator-rails/public/favicon.ico
|
206
208
|
- examples/determinator-rails/public/robots.txt
|
207
209
|
- lib/determinator.rb
|
@@ -249,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
251
|
- !ruby/object:Gem::Version
|
250
252
|
version: '0'
|
251
253
|
requirements: []
|
252
|
-
rubygems_version: 3.0.3
|
254
|
+
rubygems_version: 3.0.3.1
|
253
255
|
signing_key:
|
254
256
|
specification_version: 4
|
255
257
|
summary: Determine which experiments and features a specific actor should see.
|
@@ -1,7 +0,0 @@
|
|
1
|
-
ROUTEMASTER_DRAIN_TOKENS=demo
|
2
|
-
ROUTEMASTER_DRAIN_REDIS=redis://localhost/0/routemaster/drain
|
3
|
-
ROUTEMASTER_CACHE_REDIS=redis://localhost/0/routemaster/cache
|
4
|
-
ROUTEMASTER_CACHE_AUTH=
|
5
|
-
ROUTEMASTER_QUEUE_ADAPTER=sidekiq
|
6
|
-
ROUTEMASTER_QUEUE_NAME=routemaster
|
7
|
-
ROUTEMASTER_CALLBACK_URL=https://determinator-example.dev/events
|