flipper 0.23.0 → 0.23.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +10 -0
- data/lib/flipper/railtie.rb +18 -17
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/middleware/memoizer_spec.rb +0 -1
- data/spec/flipper/railtie_spec.rb +26 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a41bf1dd43734d1d6c6b56a46ea393af74164d46aadd7671994bdcc10e4eb646
|
4
|
+
data.tar.gz: e935dc1375a66156f0d0f7ba967269d184b8babaf119333c614943643f760ed7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82d249a9f90b96fcf88713890a2df5a7fa5f05927b7a1903630e276507ee709b5426b91fba46aa6ef034e15dc6b50b35781d61b56afe512a46673e4de3eb559d
|
7
|
+
data.tar.gz: c986d6fb7c1a773ab56e6b7cb35734648485562690799dff901578b2c31566f5582bb8390268228f48eda9fba6797f8b72bd7fd385e45a9a04155c14a4c8b95f
|
data/Changelog.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 0.23.1
|
2
|
+
|
3
|
+
### Additions/Changes
|
4
|
+
|
5
|
+
* Relax dalli version constraint (https://github.com/jnunemaker/flipper/pull/596)
|
6
|
+
|
7
|
+
### Bug Fixes
|
8
|
+
|
9
|
+
* Fix railtie initialization to mount middleware after config/intializers/* (https://github.com/jnunemaker/flipper/pull/586)
|
10
|
+
|
1
11
|
## 0.23.0
|
2
12
|
|
3
13
|
### Additions/Changes
|
data/lib/flipper/railtie.rb
CHANGED
@@ -10,6 +10,12 @@ module Flipper
|
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
13
|
+
initializer "flipper.identifier" do
|
14
|
+
ActiveSupport.on_load(:active_record) do
|
15
|
+
ActiveRecord::Base.include Flipper::Identifier
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
13
19
|
initializer "flipper.default", before: :load_config_initializers do |app|
|
14
20
|
Flipper.configure do |config|
|
15
21
|
config.default do
|
@@ -18,28 +24,23 @@ module Flipper
|
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
21
|
-
initializer "flipper.
|
22
|
-
|
27
|
+
initializer "flipper.log", after: :load_config_initializers do |app|
|
28
|
+
flipper = app.config.flipper
|
23
29
|
|
24
|
-
if
|
25
|
-
app.middleware.use Flipper::Middleware::Memoizer, {
|
26
|
-
env_key: config.env_key,
|
27
|
-
preload: config.preload,
|
28
|
-
if: config.memoize.respond_to?(:call) ? config.memoize : nil
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
initializer "flipper.log" do |app|
|
34
|
-
config = app.config.flipper
|
35
|
-
if config.log && config.instrumenter == ActiveSupport::Notifications
|
30
|
+
if flipper.log && flipper.instrumenter == ActiveSupport::Notifications
|
36
31
|
require "flipper/instrumentation/log_subscriber"
|
37
32
|
end
|
38
33
|
end
|
39
34
|
|
40
|
-
initializer "flipper.
|
41
|
-
|
42
|
-
|
35
|
+
initializer "flipper.memoizer", after: :load_config_initializers do |app|
|
36
|
+
flipper = app.config.flipper
|
37
|
+
|
38
|
+
if flipper.memoize
|
39
|
+
app.middleware.use Flipper::Middleware::Memoizer, {
|
40
|
+
env_key: flipper.env_key,
|
41
|
+
preload: flipper.preload,
|
42
|
+
if: flipper.memoize.respond_to?(:call) ? flipper.memoize : nil
|
43
|
+
}
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -3,11 +3,8 @@ require 'flipper/railtie'
|
|
3
3
|
|
4
4
|
RSpec.describe Flipper::Railtie do
|
5
5
|
let(:application) do
|
6
|
-
Class.new(Rails::Application).
|
7
|
-
|
8
|
-
).tap do |app|
|
9
|
-
app.config.eager_load = false
|
10
|
-
app.run_load_hooks!
|
6
|
+
Class.new(Rails::Application).create(railties: [Flipper::Railtie]) do
|
7
|
+
config.eager_load = false
|
11
8
|
end
|
12
9
|
end
|
13
10
|
|
@@ -22,40 +19,42 @@ RSpec.describe Flipper::Railtie do
|
|
22
19
|
|
23
20
|
describe 'initializers' do
|
24
21
|
it 'sets defaults' do
|
22
|
+
subject # initialize
|
25
23
|
expect(config.env_key).to eq("flipper")
|
26
24
|
expect(config.memoize).to be(true)
|
27
25
|
expect(config.preload).to be(true)
|
28
26
|
end
|
29
27
|
|
30
28
|
it "configures instrumentor on default instance" do
|
31
|
-
subject
|
32
|
-
|
29
|
+
subject # initialize
|
33
30
|
expect(Flipper.instance.instrumenter).to eq(ActiveSupport::Notifications)
|
34
31
|
end
|
35
32
|
|
36
33
|
it 'uses Memoizer middleware if config.memoize = true' do
|
34
|
+
initializer { config.memoize = true }
|
37
35
|
expect(subject.middleware).to include(Flipper::Middleware::Memoizer)
|
38
36
|
end
|
39
37
|
|
40
38
|
it 'does not use Memoizer middleware if config.memoize = false' do
|
41
|
-
|
42
|
-
config.memoize = false
|
43
|
-
|
39
|
+
initializer { config.memoize = false }
|
44
40
|
expect(subject.middleware).not_to include(Flipper::Middleware::Memoizer)
|
45
41
|
end
|
46
42
|
|
47
43
|
it 'passes config to memoizer' do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
expect(Flipper::Middleware::Memoizer).to receive(:new).with(application.routes,
|
55
|
-
env_key: 'my_flipper', preload: [:stats, :search], if: nil
|
56
|
-
)
|
44
|
+
initializer do
|
45
|
+
config.update(
|
46
|
+
env_key: 'my_flipper',
|
47
|
+
preload: [:stats, :search]
|
48
|
+
)
|
49
|
+
end
|
57
50
|
|
58
|
-
subject
|
51
|
+
expect(subject.middleware).to include(Flipper::Middleware::Memoizer)
|
52
|
+
middleware = subject.middleware.detect { |m| m.klass == Flipper::Middleware::Memoizer }
|
53
|
+
expect(middleware.args[0]).to eq({
|
54
|
+
env_key: config.env_key,
|
55
|
+
preload: config.preload,
|
56
|
+
if: nil
|
57
|
+
})
|
59
58
|
end
|
60
59
|
|
61
60
|
it "defines #flipper_id on AR::Base" do
|
@@ -64,4 +63,11 @@ RSpec.describe Flipper::Railtie do
|
|
64
63
|
expect(ActiveRecord::Base.ancestors).to include(Flipper::Identifier)
|
65
64
|
end
|
66
65
|
end
|
66
|
+
|
67
|
+
# Add app initializer in the same order as config/initializers/*
|
68
|
+
def initializer(&block)
|
69
|
+
application.initializer 'spec', before: :load_config_initializers do
|
70
|
+
block.call
|
71
|
+
end
|
72
|
+
end
|
67
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|