flipper 0.23.0 → 0.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +8 -4
- data/.github/workflows/examples.yml +13 -3
- data/Changelog.md +30 -0
- data/Dockerfile +1 -1
- data/lib/flipper/actor.rb +4 -0
- data/lib/flipper/dsl.rb +4 -2
- data/lib/flipper/railtie.rb +18 -17
- data/lib/flipper/types/actor.rb +8 -2
- data/lib/flipper/types/group.rb +8 -1
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/actor_spec.rb +10 -0
- data/spec/flipper/dsl_spec.rb +13 -3
- data/spec/flipper/middleware/memoizer_spec.rb +0 -1
- data/spec/flipper/railtie_spec.rb +26 -20
- data/spec/spec_helper.rb +1 -0
- 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: a73ea66b4ab3342f5cf63a162bf8b0482fdc644dc0fff38fcb2d3fa2b39015be
|
4
|
+
data.tar.gz: a680008dad6bc0affee30e0d150aab5cc869d46d37ac2ae3ce8b7b2f57de9e9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50d1ff58301b4040e2ac0ed6590c057952f3c926aa88371858cec083be2d5fcdb17920fa120f6c59f9a5625ad2260aa0cdf40c26dfa64239a4790f247287c720
|
7
|
+
data.tar.gz: 40d68ac75fde3051cece778aa09145891ca3cf289abb795c66695f3e3fac569c28e81864d3be386d7ab03d0fd9c1b9c303fca6f5865ef6a2cd4eb9edbdc12eee
|
data/.github/workflows/ci.yml
CHANGED
@@ -15,13 +15,17 @@ jobs:
|
|
15
15
|
--health-retries 5
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
ruby: ['2.
|
18
|
+
ruby: ['2.6', '2.7', '3.0', '3.1']
|
19
19
|
rails: ['5.2', '6.0.0', '6.1.0', '7.0.0']
|
20
20
|
exclude:
|
21
|
-
- ruby: "2.5"
|
22
|
-
rails: "7.0.0"
|
23
21
|
- ruby: "2.6"
|
24
22
|
rails: "7.0.0"
|
23
|
+
- ruby: "3.0"
|
24
|
+
rails: "5.2"
|
25
|
+
- ruby: "3.1"
|
26
|
+
rails: "5.2"
|
27
|
+
- ruby: "3.1"
|
28
|
+
rails: "6.0.0"
|
25
29
|
env:
|
26
30
|
SQLITE3_VERSION: 1.4.1
|
27
31
|
REDIS_URL: redis://localhost:6379/0
|
@@ -43,7 +47,7 @@ jobs:
|
|
43
47
|
restore-keys: |
|
44
48
|
${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
|
45
49
|
- name: Set up Ruby ${{ matrix.ruby }}
|
46
|
-
uses:
|
50
|
+
uses: ruby/setup-ruby@v1
|
47
51
|
with:
|
48
52
|
ruby-version: ${{ matrix.ruby }}
|
49
53
|
- name: Install libpq-dev
|
@@ -16,8 +16,18 @@ jobs:
|
|
16
16
|
--health-retries 5
|
17
17
|
strategy:
|
18
18
|
matrix:
|
19
|
-
ruby: ['2.
|
20
|
-
rails: ['5.2', '6.0.0', '6.1.0']
|
19
|
+
ruby: ['2.6', '2.7', '3.0', '3.1']
|
20
|
+
rails: ['5.2', '6.0.0', '6.1.0', '7.0.0']
|
21
|
+
exclude:
|
22
|
+
- ruby: "2.6"
|
23
|
+
rails: "7.0.0"
|
24
|
+
- ruby: "3.0"
|
25
|
+
rails: "5.2"
|
26
|
+
- ruby: "3.1"
|
27
|
+
rails: "5.2"
|
28
|
+
- ruby: "3.1"
|
29
|
+
rails: "6.0.0"
|
30
|
+
|
21
31
|
env:
|
22
32
|
SQLITE3_VERSION: 1.4.1
|
23
33
|
REDIS_URL: redis://localhost:6379/0
|
@@ -39,7 +49,7 @@ jobs:
|
|
39
49
|
restore-keys: |
|
40
50
|
${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
|
41
51
|
- name: Set up Ruby ${{ matrix.ruby }}
|
42
|
-
uses:
|
52
|
+
uses: ruby/setup-ruby@v1
|
43
53
|
with:
|
44
54
|
ruby-version: ${{ matrix.ruby }}
|
45
55
|
- name: Install libpq-dev
|
data/Changelog.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
## 0.24.1
|
2
|
+
|
3
|
+
### Additions/Changes
|
4
|
+
|
5
|
+
* flipper-api: `exclude_gates` parameter to exclude gate data in GETs (https://github.com/jnunemaker/flipper/pull/572).
|
6
|
+
* Make it possible to disable internal memoization (https://github.com/jnunemaker/flipper/pull/612).
|
7
|
+
* Add Flipper::Actor#hash so actors can be hash keys (https://github.com/jnunemaker/flipper/pull/616).
|
8
|
+
* Pretty Up `rails routes` again and make rack-protection dependency less strict (https://github.com/jnunemaker/flipper/pull/619).
|
9
|
+
* Add kwargs for method_missing using ruby 3.0 (https://github.com/jnunemaker/flipper/pull/620).
|
10
|
+
|
11
|
+
## 0.24.0
|
12
|
+
|
13
|
+
### Additions/Changes
|
14
|
+
|
15
|
+
* Add Ruby 3.0 and 3.1 to the CI matrix and fix groups block arity check for ruby 3 (https://github.com/jnunemaker/flipper/pull/601)
|
16
|
+
* Removed support for Ruby 2.5 (which was end of line 9 months ago)
|
17
|
+
* Add (alpha) client side instrumentation of events to cloud (https://github.com/jnunemaker/flipper/pull/602)
|
18
|
+
* Fix deprecated uses of Redis#pipelined (https://github.com/jnunemaker/flipper/pull/603). redis-rb >= 3 now required.
|
19
|
+
* Fix Flipper UI Rack application when `Rack::Session::Pool` is used to build it (https://github.com/jnunemaker/flipper/pull/606).
|
20
|
+
|
21
|
+
## 0.23.1
|
22
|
+
|
23
|
+
### Additions/Changes
|
24
|
+
|
25
|
+
* Relax dalli version constraint (https://github.com/jnunemaker/flipper/pull/596)
|
26
|
+
|
27
|
+
### Bug Fixes
|
28
|
+
|
29
|
+
* Fix railtie initialization to mount middleware after config/intializers/* (https://github.com/jnunemaker/flipper/pull/586)
|
30
|
+
|
1
31
|
## 0.23.0
|
2
32
|
|
3
33
|
### Additions/Changes
|
data/Dockerfile
CHANGED
data/lib/flipper/actor.rb
CHANGED
data/lib/flipper/dsl.rb
CHANGED
@@ -17,10 +17,12 @@ module Flipper
|
|
17
17
|
# adapter - The adapter that this DSL instance should use.
|
18
18
|
# options - The Hash of options.
|
19
19
|
# :instrumenter - What should be used to instrument all the things.
|
20
|
+
# :memoize - Should adapter be wrapped by memoize adapter or not.
|
20
21
|
def initialize(adapter, options = {})
|
21
22
|
@instrumenter = options.fetch(:instrumenter, Instrumenters::Noop)
|
22
|
-
|
23
|
-
|
23
|
+
memoize = options.fetch(:memoize, true)
|
24
|
+
adapter = Adapters::Memoizable.new(adapter) if memoize
|
25
|
+
@adapter = adapter
|
24
26
|
@memoized_features = {}
|
25
27
|
end
|
26
28
|
|
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/types/actor.rb
CHANGED
@@ -23,8 +23,14 @@ module Flipper
|
|
23
23
|
super || @thing.respond_to?(*args)
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
if RUBY_VERSION >= '3.0'
|
27
|
+
def method_missing(name, *args, **kwargs, &block)
|
28
|
+
@thing.send name, *args, **kwargs, &block
|
29
|
+
end
|
30
|
+
else
|
31
|
+
def method_missing(name, *args, &block)
|
32
|
+
@thing.send name, *args, &block
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
data/lib/flipper/types/group.rb
CHANGED
@@ -14,7 +14,7 @@ module Flipper
|
|
14
14
|
|
15
15
|
if block_given?
|
16
16
|
@block = block
|
17
|
-
@single_argument = @block
|
17
|
+
@single_argument = call_with_no_context?(@block)
|
18
18
|
else
|
19
19
|
@block = ->(_thing, _context) { false }
|
20
20
|
@single_argument = false
|
@@ -28,6 +28,13 @@ module Flipper
|
|
28
28
|
@block.call(thing, context)
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
NO_PARAMS_IN_RUBY_3 = [[:req], [:rest]]
|
33
|
+
def call_with_no_context?(block)
|
34
|
+
return true if block.parameters == NO_PARAMS_IN_RUBY_3
|
35
|
+
|
36
|
+
block.arity.abs == 1
|
37
|
+
end
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
data/lib/flipper/version.rb
CHANGED
data/spec/flipper/actor_spec.rb
CHANGED
@@ -43,4 +43,14 @@ RSpec.describe Flipper::Actor do
|
|
43
43
|
expect(actor1.==(actor2)).to be(false)
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
describe '#hash' do
|
48
|
+
it 'returns a hash-value based on the flipper id' do
|
49
|
+
h = {
|
50
|
+
described_class.new("User;123") => true
|
51
|
+
}
|
52
|
+
expect(h).to have_key(described_class.new("User;123"))
|
53
|
+
expect(h).not_to have_key(described_class.new("User;456"))
|
54
|
+
end
|
55
|
+
end
|
46
56
|
end
|
data/spec/flipper/dsl_spec.rb
CHANGED
@@ -6,9 +6,19 @@ RSpec.describe Flipper::DSL do
|
|
6
6
|
let(:adapter) { Flipper::Adapters::Memory.new }
|
7
7
|
|
8
8
|
describe '#initialize' do
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
context 'when using default memoize strategy' do
|
10
|
+
it 'wraps the given adapter with Flipper::Adapters::Memoizable' do
|
11
|
+
dsl = described_class.new(adapter)
|
12
|
+
expect(dsl.adapter.class).to be(Flipper::Adapters::Memoizable)
|
13
|
+
expect(dsl.adapter.adapter).to be(adapter)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when disabling memoization' do
|
18
|
+
it 'uses the given adapter directly' do
|
19
|
+
dsl = described_class.new(adapter, memoize: false)
|
20
|
+
expect(dsl.adapter).to be(adapter)
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
24
|
it 'defaults instrumenter to noop' do
|
@@ -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
|
data/spec/spec_helper.rb
CHANGED
@@ -22,6 +22,7 @@ Dir[FlipperRoot.join('spec/support/**/*.rb')].sort.each { |f| require f }
|
|
22
22
|
|
23
23
|
RSpec.configure do |config|
|
24
24
|
config.before(:example) do
|
25
|
+
Flipper::Cloud::Registry.default.clear if defined?(Flipper::Cloud)
|
25
26
|
Flipper.unregister_groups
|
26
27
|
Flipper.configuration = nil
|
27
28
|
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.
|
4
|
+
version: 0.24.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-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|