flipper 0.24.1 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a73ea66b4ab3342f5cf63a162bf8b0482fdc644dc0fff38fcb2d3fa2b39015be
4
- data.tar.gz: a680008dad6bc0affee30e0d150aab5cc869d46d37ac2ae3ce8b7b2f57de9e9b
3
+ metadata.gz: a830f8560a3b19ddb21ec12dba61ec973a5f0aa134d2f3d6d04371c4cf1ecb98
4
+ data.tar.gz: '0973ab983f4ae2351023a4b2ec9239434188671bc27bb4c4a95d5bc9d5521471'
5
5
  SHA512:
6
- metadata.gz: 50d1ff58301b4040e2ac0ed6590c057952f3c926aa88371858cec083be2d5fcdb17920fa120f6c59f9a5625ad2260aa0cdf40c26dfa64239a4790f247287c720
7
- data.tar.gz: 40d68ac75fde3051cece778aa09145891ca3cf289abb795c66695f3e3fac569c28e81864d3be386d7ab03d0fd9c1b9c303fca6f5865ef6a2cd4eb9edbdc12eee
6
+ metadata.gz: 0db89e65773952f1394bf8db244a1b4ca7365f3c962ee051f6140b7365a3785eb6e7870f7adb6bec5032b863e3e28b618d2d7e6f2d093441881c1b5c856a4467
7
+ data.tar.gz: 4d8226964f2a5d5434ac2aae7ee81062058e8210863c272abf04ffa6f4363345d55ad55b4126ab22b8f5bc937c212561f4584e03d980f7fcc16adb75aa4d4481
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -34,13 +34,13 @@ jobs:
34
34
  - name: Setup memcached
35
35
  uses: KeisukeYamashita/memcached-actions@v1
36
36
  - name: Start MongoDB
37
- uses: supercharge/mongodb-github-action@1.3.0
37
+ uses: supercharge/mongodb-github-action@1.7.0
38
38
  with:
39
39
  mongodb-version: 4.0
40
40
  - name: Check out repository code
41
- uses: actions/checkout@v2
41
+ uses: actions/checkout@v3
42
42
  - name: Do some action caching
43
- uses: actions/cache@v1
43
+ uses: actions/cache@v3
44
44
  with:
45
45
  path: vendor/bundle
46
46
  key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
@@ -36,13 +36,13 @@ jobs:
36
36
  - name: Setup memcached
37
37
  uses: KeisukeYamashita/memcached-actions@v1
38
38
  - name: Start MongoDB
39
- uses: supercharge/mongodb-github-action@1.3.0
39
+ uses: supercharge/mongodb-github-action@1.7.0
40
40
  with:
41
41
  mongodb-version: 4.0
42
42
  - name: Check out repository code
43
- uses: actions/checkout@v2
43
+ uses: actions/checkout@v3
44
44
  - name: Do some action caching
45
- uses: actions/cache@v1
45
+ uses: actions/cache@v3
46
46
  with:
47
47
  path: vendor/bundle
48
48
  key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
@@ -0,0 +1,44 @@
1
+ # https://andrewm.codes/blog/automating-ruby-gem-releases-with-github-actions/
2
+ name: release
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ release-please:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: google-github-actions/release-please-action@v3
14
+ id: release
15
+ with:
16
+ release-type: ruby
17
+ package-name: flipper
18
+ bump-minor-pre-major: true
19
+ version-file: "lib/flipper/version.rb"
20
+ # Checkout code if release was created
21
+ - uses: actions/checkout@v2
22
+ if: ${{ steps.release.outputs.release_created }}
23
+ # Setup ruby if a release was created
24
+ - uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: 3.0.0
27
+ if: ${{ steps.release.outputs.release_created }}
28
+ # Bundle install
29
+ - run: bundle install
30
+ if: ${{ steps.release.outputs.release_created }}
31
+ # Publish
32
+ - name: publish gem
33
+ run: |
34
+ mkdir -p $HOME/.gem
35
+ touch $HOME/.gem/credentials
36
+ chmod 0600 $HOME/.gem/credentials
37
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
38
+ gem build *.gemspec
39
+ gem push *.gem
40
+ env:
41
+ # Make sure to update the secret name
42
+ # if yours isn't named RUBYGEMS_AUTH_TOKEN
43
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
44
+ if: ${{ steps.release.outputs.release_created }}
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.1.2
data/Changelog.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 0.25.2
2
+
3
+ * Fix deprecation warnings for Redis >= 4.8.0 (https://github.com/jnunemaker/flipper/pull/660)
4
+
5
+ ## 0.25.1
6
+
7
+ ### Additions/Changes
8
+
9
+ * ActiveRecord: use provided `gate_class` option when calling `#get_all` (https://github.com/jnunemaker/flipper/pull/647)
10
+ * Relaxed the rack-protection version to support latest (https://github.com/jnunemaker/flipper/commit/f4a41c541ccf14c535a61c6bc6fe7eeabbfc7e71).
11
+ * Configure ActiveRecord adapter immediately upon require of flipper-active_record (https://github.com/jnunemaker/flipper/pull/652)
12
+
13
+ ## 0.25.0
14
+
15
+ ### Additions/Changes
16
+
17
+ * Added a prompt in Flipper UI for the 'Delete' button to prevent accidental delete of features (https://github.com/jnunemaker/flipper/pull/625)
18
+ * Added failsafe adapter (https://github.com/jnunemaker/flipper/pull/626)
19
+ * Removed previously deprecated options and settings. Those upgrading from `<0.21` should upgrade to `~>0.24` first and fix any deprecation warnings when initializing Flipper. (https://github.com/jnunemaker/flipper/pull/627)
20
+ * ActiveRecord: base class for internal models (https://github.com/jnunemaker/flipper/pull/629)
21
+ * Remove use of `Rack::BodyProxy` in the memoizer middleware (https://github.com/jnunemaker/flipper/pull/631)
22
+
1
23
  ## 0.24.1
2
24
 
3
25
  ### Additions/Changes
@@ -7,6 +29,7 @@
7
29
  * Add Flipper::Actor#hash so actors can be hash keys (https://github.com/jnunemaker/flipper/pull/616).
8
30
  * Pretty Up `rails routes` again and make rack-protection dependency less strict (https://github.com/jnunemaker/flipper/pull/619).
9
31
  * Add kwargs for method_missing using ruby 3.0 (https://github.com/jnunemaker/flipper/pull/620).
32
+ * Relax the rack-protection dependency (https://github.com/jnunemaker/flipper/commit/c1cb9cd78140c2b09123687642558101e6e5d37d).
10
33
 
11
34
  ## 0.24.0
12
35
 
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ Dir['flipper-*.gemspec'].each do |gemspec|
6
6
  gemspec(name: "flipper-#{plugin}", development_group: plugin)
7
7
  end
8
8
 
9
- gem 'pry'
9
+ gem 'debug'
10
10
  gem 'rake', '~> 12.3.3'
11
11
  gem 'shotgun', '~> 0.9'
12
12
  gem 'statsd-ruby', '~> 1.2.1'
@@ -1,5 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require 'securerandom'
3
+ require 'active_support/isolated_execution_state'
3
4
  require 'active_support/notifications'
4
5
 
5
6
  class FlipperSubscriber
@@ -1,6 +1,7 @@
1
1
  # Quick example of how to keep track of when a feature was last checked.
2
2
  require 'bundler/setup'
3
3
  require 'securerandom'
4
+ require 'active_support/isolated_execution_state'
4
5
  require 'active_support/notifications'
5
6
  require 'flipper'
6
7
 
@@ -0,0 +1,76 @@
1
+ module Flipper
2
+ module Adapters
3
+ class Failsafe
4
+ include ::Flipper::Adapter
5
+
6
+ # Public: The name of the adapter.
7
+ attr_reader :name
8
+
9
+ # Public: Build a new Failsafe instance.
10
+ #
11
+ # adapter - Flipper adapter to guard.
12
+ # options - Hash of options:
13
+ # :errors - Array of exception types for which to fail safe
14
+
15
+ def initialize(adapter, options = {})
16
+ @adapter = adapter
17
+ @errors = options.fetch(:errors, [StandardError])
18
+ @name = :failsafe
19
+ end
20
+
21
+ def features
22
+ @adapter.features
23
+ rescue *@errors
24
+ Set.new
25
+ end
26
+
27
+ def add(feature)
28
+ @adapter.add(feature)
29
+ rescue *@errors
30
+ false
31
+ end
32
+
33
+ def remove(feature)
34
+ @adapter.remove(feature)
35
+ rescue *@errors
36
+ false
37
+ end
38
+
39
+ def clear(feature)
40
+ @adapter.clear(feature)
41
+ rescue *@errors
42
+ false
43
+ end
44
+
45
+ def get(feature)
46
+ @adapter.get(feature)
47
+ rescue *@errors
48
+ {}
49
+ end
50
+
51
+ def get_multi(features)
52
+ @adapter.get_multi(features)
53
+ rescue *@errors
54
+ {}
55
+ end
56
+
57
+ def get_all
58
+ @adapter.get_all
59
+ rescue *@errors
60
+ {}
61
+ end
62
+
63
+ def enable(feature, gate, thing)
64
+ @adapter.enable(feature, gate, thing)
65
+ rescue *@errors
66
+ false
67
+ end
68
+
69
+ def disable(feature, gate, thing)
70
+ @adapter.disable(feature, gate, thing)
71
+ rescue *@errors
72
+ false
73
+ end
74
+ end
75
+ end
76
+ end
@@ -12,15 +12,6 @@ module Flipper
12
12
  # Raised when attempting to declare a group name that has already been used.
13
13
  class DuplicateGroup < Error; end
14
14
 
15
- # Raised when default instance not configured but there is an attempt to
16
- # use it.
17
- class DefaultNotSet < Flipper::Error
18
- def initialize(message = nil)
19
- warn "Flipper::DefaultNotSet is deprecated and will be removed in 1.0"
20
- super
21
- end
22
- end
23
-
24
15
  # Raised when an invalid value is set to a configuration property
25
16
  class InvalidConfigurationValue < Flipper::Error
26
17
  def initialize(message = nil)
@@ -28,12 +19,4 @@ module Flipper
28
19
  super(message || default)
29
20
  end
30
21
  end
31
-
32
- # Raised when accessing a configuration property that has been deprecated
33
- class ConfigurationDeprecated < Flipper::Error
34
- def initialize(message = nil)
35
- default = "The configuration property has been deprecated"
36
- super(message || default)
37
- end
38
- end
39
22
  end
@@ -25,11 +25,6 @@ module Flipper
25
25
  raise 'Flipper::Middleware::Memoizer no longer initializes with a flipper instance or block. Read more at: https://git.io/vSo31.'
26
26
  end
27
27
 
28
- if opts[:preload_all]
29
- warn "Flipper::Middleware::Memoizer: `preload_all` is deprecated, use `preload: true`"
30
- opts[:preload] = true
31
- end
32
-
33
28
  @app = app
34
29
  @opts = opts
35
30
  @env_key = opts.fetch(:env_key, 'flipper')
@@ -74,14 +69,9 @@ module Flipper
74
69
  when Array then flipper.preload(@opts[:preload])
75
70
  end
76
71
 
77
- response = @app.call(env)
78
- response[2] = Rack::BodyProxy.new(response[2]) do
79
- flipper.memoize = false
80
- end
81
- reset_on_body_close = true
82
- response
72
+ @app.call(env)
83
73
  ensure
84
- flipper.memoize = false if flipper && !reset_on_body_close
74
+ flipper.memoize = false if flipper
85
75
  end
86
76
  end
87
77
  end
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.24.1'.freeze
2
+ VERSION = '0.25.2'.freeze
3
3
  end
@@ -0,0 +1,58 @@
1
+ require 'flipper/adapters/failsafe'
2
+
3
+ RSpec.describe Flipper::Adapters::Failsafe do
4
+ subject { described_class.new(memory_adapter, options) }
5
+
6
+ let(:memory_adapter) { Flipper::Adapters::Memory.new }
7
+ let(:options) { {} }
8
+ let(:flipper) { Flipper.new(subject) }
9
+
10
+ it_should_behave_like 'a flipper adapter'
11
+
12
+ context 'when disaster strikes' do
13
+ before do
14
+ expect(flipper[feature.name].enable).to be(true)
15
+
16
+ (subject.methods - Object.methods).each do |method_name|
17
+ allow(memory_adapter).to receive(method_name).and_raise(IOError)
18
+ end
19
+ end
20
+
21
+ let(:feature) { Flipper::Feature.new(:my_feature, subject) }
22
+
23
+ it { expect(subject.features).to eq(Set.new) }
24
+ it { expect(feature.add).to eq(false) }
25
+ it { expect(feature.remove).to eq(false) }
26
+ it { expect(feature.clear).to eq(false) }
27
+ it { expect(subject.get(feature)).to eq({}) }
28
+ it { expect(subject.get_multi([feature])).to eq({}) }
29
+ it { expect(subject.get_all).to eq({}) }
30
+ it { expect(feature.enable).to eq(false) }
31
+ it { expect(feature.disable).to eq(false) }
32
+
33
+ context 'when used via Flipper' do
34
+ it { expect(flipper.features).to eq(Set.new) }
35
+ it { expect(flipper[feature.name].enabled?).to eq(false) }
36
+ it { expect(flipper[feature.name].enable).to eq(false) }
37
+ it { expect(flipper[feature.name].disable).to eq(false) }
38
+ end
39
+
40
+ context 'when there is a syntax error' do
41
+ let(:test) { flipper[feature.name].enabled? }
42
+
43
+ before do
44
+ expect(memory_adapter).to receive(:get).and_raise(SyntaxError)
45
+ end
46
+
47
+ it 'does not catch this type of error' do
48
+ expect { test }.to raise_error(SyntaxError)
49
+ end
50
+
51
+ context 'when configured to catch SyntaxError' do
52
+ let(:options) { { errors: [SyntaxError] } }
53
+
54
+ it { expect(test).to eq(false) }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -38,26 +38,6 @@ RSpec.describe Flipper::Middleware::Memoizer do
38
38
  expect(called).to eq(true)
39
39
  end
40
40
 
41
- it 'disables local cache after body close' do
42
- app = ->(_env) { [200, {}, []] }
43
- middleware = described_class.new(app)
44
- body = middleware.call(env).last
45
-
46
- expect(flipper.memoizing?).to eq(true)
47
- body.close
48
- expect(flipper.memoizing?).to eq(false)
49
- end
50
-
51
- it 'clears local cache after body close' do
52
- app = ->(_env) { [200, {}, []] }
53
- middleware = described_class.new(app)
54
- body = middleware.call(env).last
55
-
56
- flipper.adapter.cache['hello'] = 'world'
57
- body.close
58
- expect(flipper.adapter.cache).to be_empty
59
- end
60
-
61
41
  it 'clears the local cache with a successful request' do
62
42
  flipper.adapter.cache['hello'] = 'world'
63
43
  get '/', {}, 'flipper' => flipper
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,7 @@ require 'bundler'
9
9
 
10
10
  Bundler.setup(:default)
11
11
 
12
- require 'pry'
12
+ require 'debug'
13
13
  require 'webmock/rspec'
14
14
  WebMock.disable_net_connect!(allow_localhost: true)
15
15
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.1
4
+ version: 0.25.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-13 00:00:00.000000000 Z
11
+ date: 2022-08-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email:
15
15
  - nunemaker@gmail.com
16
16
  executables: []
@@ -18,9 +18,12 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ".codeclimate.yml"
21
+ - ".github/dependabot.yml"
21
22
  - ".github/workflows/ci.yml"
22
23
  - ".github/workflows/examples.yml"
24
+ - ".github/workflows/release.yml"
23
25
  - ".rspec"
26
+ - ".tool-versions"
24
27
  - CODE_OF_CONDUCT.md
25
28
  - Changelog.md
26
29
  - Dockerfile
@@ -57,6 +60,7 @@ files:
57
60
  - lib/flipper/adapter.rb
58
61
  - lib/flipper/adapters/dual_write.rb
59
62
  - lib/flipper/adapters/failover.rb
63
+ - lib/flipper/adapters/failsafe.rb
60
64
  - lib/flipper/adapters/http.rb
61
65
  - lib/flipper/adapters/http/client.rb
62
66
  - lib/flipper/adapters/http/error.rb
@@ -110,6 +114,7 @@ files:
110
114
  - spec/flipper/adapter_spec.rb
111
115
  - spec/flipper/adapters/dual_write_spec.rb
112
116
  - spec/flipper/adapters/failover_spec.rb
117
+ - spec/flipper/adapters/failsafe_spec.rb
113
118
  - spec/flipper/adapters/http_spec.rb
114
119
  - spec/flipper/adapters/instrumented_spec.rb
115
120
  - spec/flipper/adapters/memoizable_spec.rb
@@ -163,7 +168,7 @@ licenses:
163
168
  - MIT
164
169
  metadata:
165
170
  changelog_uri: https://github.com/jnunemaker/flipper/blob/master/Changelog.md
166
- post_install_message:
171
+ post_install_message:
167
172
  rdoc_options: []
168
173
  require_paths:
169
174
  - lib
@@ -178,8 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
183
  - !ruby/object:Gem::Version
179
184
  version: '0'
180
185
  requirements: []
181
- rubygems_version: 3.1.2
182
- signing_key:
186
+ rubygems_version: 3.3.7
187
+ signing_key:
183
188
  specification_version: 4
184
189
  summary: Feature flipper for ANYTHING
185
190
  test_files:
@@ -188,6 +193,7 @@ test_files:
188
193
  - spec/flipper/adapter_spec.rb
189
194
  - spec/flipper/adapters/dual_write_spec.rb
190
195
  - spec/flipper/adapters/failover_spec.rb
196
+ - spec/flipper/adapters/failsafe_spec.rb
191
197
  - spec/flipper/adapters/http_spec.rb
192
198
  - spec/flipper/adapters/instrumented_spec.rb
193
199
  - spec/flipper/adapters/memoizable_spec.rb