flipper 0.17.1 → 0.17.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 +4 -4
 - data/.rubocop.yml +2 -2
 - data/.rubocop_todo.yml +6 -6
 - data/Changelog.md +9 -0
 - data/docs/Gates.md +1 -1
 - data/flipper.gemspec +4 -4
 - data/lib/flipper/adapters/memory.rb +4 -1
 - data/lib/flipper/adapters/pstore.rb +4 -1
 - data/lib/flipper/middleware/memoizer.rb +1 -1
 - data/lib/flipper/spec/shared_adapter_specs.rb +15 -0
 - data/lib/flipper/test/shared_adapter_test.rb +16 -0
 - data/lib/flipper/version.rb +1 -1
 - data/spec/helper.rb +1 -1
 - data/test/test_helper.rb +1 -1
 - 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: 74b7be3b37819e554e11bfc661794d50f90804ae5665bd7913c08239bb2d14aa
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1045e365f31c98ce51e441d0ea0aacac5eeb36e4a9158aa246bd9c3fa778ab81
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 78acbd2f020a59b1b4912cea78715195e6956918a3c4ad5158053a233709d98ee73f464b6f24bd081e25428ad04721538f8dde7ae4b76d994e421926bd9c11f9
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d81461bbaacf4028e4f1eb5c9e7ce633d94176ba42c9a5da8504f3123b5caa8c5c73355a17fd5623b5b9c0d2c3c41ab76952e923183a7ae3fbe466a034472506
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    | 
         @@ -33,7 +33,7 @@ Style/GuardClause: 
     | 
|
| 
       33 
33 
     | 
    
         
             
            Style/IfUnlessModifier:
         
     | 
| 
       34 
34 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
            Layout/LineLength:
         
     | 
| 
       37 
37 
     | 
    
         
             
              Max: 100
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
            Style/RegexpLiteral:
         
     | 
| 
         @@ -48,5 +48,5 @@ Style/TrailingCommaInHashLiteral: 
     | 
|
| 
       48 
48 
     | 
    
         
             
            RSpec/InstanceVariable:
         
     | 
| 
       49 
49 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
            Lint/ 
     | 
| 
      
 51 
     | 
    
         
            +
            Lint/SuppressedException:
         
     | 
| 
       52 
52 
     | 
    
         
             
              Enabled: false
         
     | 
    
        data/.rubocop_todo.yml
    CHANGED
    
    | 
         @@ -32,7 +32,7 @@ Gemspec/OrderedDependencies: 
     | 
|
| 
       32 
32 
     | 
    
         
             
            # SupportedHashRocketStyles: key, separator, table
         
     | 
| 
       33 
33 
     | 
    
         
             
            # SupportedColonStyles: key, separator, table
         
     | 
| 
       34 
34 
     | 
    
         
             
            # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
         
     | 
| 
       35 
     | 
    
         
            -
            Layout/ 
     | 
| 
      
 35 
     | 
    
         
            +
            Layout/HashAlignment:
         
     | 
| 
       36 
36 
     | 
    
         
             
              Exclude:
         
     | 
| 
       37 
37 
     | 
    
         
             
                - 'lib/flipper/typecast.rb'
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
         @@ -81,7 +81,7 @@ Layout/EmptyLinesAroundExceptionHandlingKeywords: 
     | 
|
| 
       81 
81 
     | 
    
         
             
            # Cop supports --auto-correct.
         
     | 
| 
       82 
82 
     | 
    
         
             
            # Configuration parameters: EnforcedStyle.
         
     | 
| 
       83 
83 
     | 
    
         
             
            # SupportedStyles: squiggly, active_support, powerpack, unindent
         
     | 
| 
       84 
     | 
    
         
            -
            Layout/ 
     | 
| 
      
 84 
     | 
    
         
            +
            Layout/HeredocIndentation:
         
     | 
| 
       85 
85 
     | 
    
         
             
              Exclude:
         
     | 
| 
       86 
86 
     | 
    
         
             
                - 'test/generators/flipper/active_record_generator_test.rb'
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
         @@ -138,13 +138,13 @@ Lint/ShadowingOuterLocalVariable: 
     | 
|
| 
       138 
138 
     | 
    
         | 
| 
       139 
139 
     | 
    
         
             
            # Offense count: 2
         
     | 
| 
       140 
140 
     | 
    
         
             
            # Cop supports --auto-correct.
         
     | 
| 
       141 
     | 
    
         
            -
            Lint/ 
     | 
| 
      
 141 
     | 
    
         
            +
            Lint/RedundantCopDisableDirective:
         
     | 
| 
       142 
142 
     | 
    
         
             
              Exclude:
         
     | 
| 
       143 
143 
     | 
    
         
             
                - 'spec/flipper/adapter_spec.rb'
         
     | 
| 
       144 
144 
     | 
    
         | 
| 
       145 
145 
     | 
    
         
             
            # Offense count: 1
         
     | 
| 
       146 
146 
     | 
    
         
             
            # Cop supports --auto-correct.
         
     | 
| 
       147 
     | 
    
         
            -
            Lint/ 
     | 
| 
      
 147 
     | 
    
         
            +
            Lint/RedundantRequireStatement:
         
     | 
| 
       148 
148 
     | 
    
         
             
              Exclude:
         
     | 
| 
       149 
149 
     | 
    
         
             
                - 'lib/flipper/registry.rb'
         
     | 
| 
       150 
150 
     | 
    
         | 
| 
         @@ -174,13 +174,13 @@ Metrics/BlockLength: 
     | 
|
| 
       174 
174 
     | 
    
         
             
            # Offense count: 11
         
     | 
| 
       175 
175 
     | 
    
         
             
            # Configuration parameters: CountComments.
         
     | 
| 
       176 
176 
     | 
    
         
             
            Metrics/ClassLength:
         
     | 
| 
       177 
     | 
    
         
            -
              Max:  
     | 
| 
      
 177 
     | 
    
         
            +
              Max: 160
         
     | 
| 
       178 
178 
     | 
    
         | 
| 
       179 
179 
     | 
    
         
             
            # Offense count: 20
         
     | 
| 
       180 
180 
     | 
    
         
             
            # Cop supports --auto-correct.
         
     | 
| 
       181 
181 
     | 
    
         
             
            # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
         
     | 
| 
       182 
182 
     | 
    
         
             
            # URISchemes: http, https
         
     | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
      
 183 
     | 
    
         
            +
            Layout/LineLength:
         
     | 
| 
       184 
184 
     | 
    
         
             
              Max: 251
         
     | 
| 
       185 
185 
     | 
    
         | 
| 
       186 
186 
     | 
    
         
             
            # Offense count: 59
         
     | 
    
        data/Changelog.md
    CHANGED
    
    | 
         @@ -1,3 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## 0.17.2
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ### Additions/Changes
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * Avoid errors on import when there are no features and shared specs/tests for get all with no features (https://github.com/jnunemaker/flipper/pull/441 and https://github.com/jnunemaker/flipper/pull/442)
         
     | 
| 
      
 6 
     | 
    
         
            +
            * ::ActiveRecord::RecordNotUnique > ActiveRecord::RecordNotUnique (https://github.com/jnunemaker/flipper/pull/444)
         
     | 
| 
      
 7 
     | 
    
         
            +
            * Clear gate values on enable (https://github.com/jnunemaker/flipper/pull/454)
         
     | 
| 
      
 8 
     | 
    
         
            +
            * Remove use of multi from redis adapter (https://github.com/jnunemaker/flipper/pull/451)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       1 
10 
     | 
    
         
             
            ## 0.17.1
         
     | 
| 
       2 
11 
     | 
    
         | 
| 
       3 
12 
     | 
    
         
             
            * Fix require in flipper-active_record (https://github.com/jnunemaker/flipper/pull/437)
         
     | 
    
        data/docs/Gates.md
    CHANGED
    
    | 
         @@ -139,7 +139,7 @@ Flipper.register(:admins) do |actor| 
     | 
|
| 
       139 
139 
     | 
    
         
             
              actor.respond_to?(:admin?) && actor.admin?
         
     | 
| 
       140 
140 
     | 
    
         
             
            end
         
     | 
| 
       141 
141 
     | 
    
         
             
            ```
         
     | 
| 
       142 
     | 
    
         
            -
            - The above first registers a group called `admins` which essentially saves a [Proc](http://www.eriktrautman.com/posts/ruby-explained-blocks-procs-and-lambdas-aka-closures) to be called later.
         
     | 
| 
      
 142 
     | 
    
         
            +
            - The above first registers a group called `admins` which essentially saves a [Proc](http://www.eriktrautman.com/posts/ruby-explained-blocks-procs-and-lambdas-aka-closures) to be called later. The `actor` is an instance of the `Flipper::Types::Actor` that wraps the thing being checked against and `actor.thing` is the original object being checked. 
         
     | 
| 
       143 
143 
     | 
    
         | 
| 
       144 
144 
     | 
    
         
             
            ```
         
     | 
| 
       145 
145 
     | 
    
         
             
            flipper[:stats].enable flipper.group(:admins)
         
     | 
    
        data/flipper.gemspec
    CHANGED
    
    | 
         @@ -25,13 +25,13 @@ Gem::Specification.new do |gem| 
     | 
|
| 
       25 
25 
     | 
    
         
             
              gem.authors       = ['John Nunemaker']
         
     | 
| 
       26 
26 
     | 
    
         
             
              gem.email         = ['nunemaker@gmail.com']
         
     | 
| 
       27 
27 
     | 
    
         
             
              gem.summary       = 'Feature flipper for ANYTHING'
         
     | 
| 
       28 
     | 
    
         
            -
              gem.description   = 'Feature flipper is the act of enabling/disabling features in your application, ideally without re-deploying or changing anything in your code base. Flipper makes this extremely easy to do with any backend you would like to use.' # rubocop:disable  
     | 
| 
      
 28 
     | 
    
         
            +
              gem.description   = 'Feature flipper is the act of enabling/disabling features in your application, ideally without re-deploying or changing anything in your code base. Flipper makes this extremely easy to do with any backend you would like to use.' # rubocop:disable Layout/LineLength
         
     | 
| 
       29 
29 
     | 
    
         
             
              gem.homepage      = 'https://github.com/jnunemaker/flipper'
         
     | 
| 
       30 
30 
     | 
    
         
             
              gem.license       = 'MIT'
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
              gem.executables   = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } 
     | 
| 
       33 
     | 
    
         
            -
              gem.files         = `git ls-files`.split("\n") - ignored_files + ['lib/flipper/version.rb'] 
     | 
| 
       34 
     | 
    
         
            -
              gem.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n") - ignored_test_files 
     | 
| 
      
 32 
     | 
    
         
            +
              gem.executables   = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
         
     | 
| 
      
 33 
     | 
    
         
            +
              gem.files         = `git ls-files`.split("\n") - ignored_files + ['lib/flipper/version.rb']
         
     | 
| 
      
 34 
     | 
    
         
            +
              gem.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n") - ignored_test_files
         
     | 
| 
       35 
35 
     | 
    
         
             
              gem.name          = 'flipper'
         
     | 
| 
       36 
36 
     | 
    
         
             
              gem.require_paths = ['lib']
         
     | 
| 
       37 
37 
     | 
    
         
             
              gem.version       = Flipper::VERSION
         
     | 
| 
         @@ -65,7 +65,10 @@ module Flipper 
     | 
|
| 
       65 
65 
     | 
    
         
             
                  # Public
         
     | 
| 
       66 
66 
     | 
    
         
             
                  def enable(feature, gate, thing)
         
     | 
| 
       67 
67 
     | 
    
         
             
                    case gate.data_type
         
     | 
| 
       68 
     | 
    
         
            -
                    when :boolean 
     | 
| 
      
 68 
     | 
    
         
            +
                    when :boolean
         
     | 
| 
      
 69 
     | 
    
         
            +
                      clear(feature)
         
     | 
| 
      
 70 
     | 
    
         
            +
                      write key(feature, gate), thing.value.to_s
         
     | 
| 
      
 71 
     | 
    
         
            +
                    when :integer
         
     | 
| 
       69 
72 
     | 
    
         
             
                      write key(feature, gate), thing.value.to_s
         
     | 
| 
       70 
73 
     | 
    
         
             
                    when :set
         
     | 
| 
       71 
74 
     | 
    
         
             
                      set_add key(feature, gate), thing.value.to_s
         
     | 
| 
         @@ -84,7 +84,10 @@ module Flipper 
     | 
|
| 
       84 
84 
     | 
    
         
             
                  def enable(feature, gate, thing)
         
     | 
| 
       85 
85 
     | 
    
         
             
                    @store.transaction do
         
     | 
| 
       86 
86 
     | 
    
         
             
                      case gate.data_type
         
     | 
| 
       87 
     | 
    
         
            -
                      when :boolean 
     | 
| 
      
 87 
     | 
    
         
            +
                      when :boolean
         
     | 
| 
      
 88 
     | 
    
         
            +
                        clear_gates(feature)
         
     | 
| 
      
 89 
     | 
    
         
            +
                        write key(feature, gate), thing.value.to_s
         
     | 
| 
      
 90 
     | 
    
         
            +
                      when :integer
         
     | 
| 
       88 
91 
     | 
    
         
             
                        write key(feature, gate), thing.value.to_s
         
     | 
| 
       89 
92 
     | 
    
         
             
                      when :set
         
     | 
| 
       90 
93 
     | 
    
         
             
                        set_add key(feature, gate), thing.value.to_s
         
     | 
| 
         @@ -23,7 +23,7 @@ module Flipper 
     | 
|
| 
       23 
23 
     | 
    
         
             
                  #
         
     | 
| 
       24 
24 
     | 
    
         
             
                  def initialize(app, opts = {})
         
     | 
| 
       25 
25 
     | 
    
         
             
                    if opts.is_a?(Flipper::DSL) || opts.is_a?(Proc)
         
     | 
| 
       26 
     | 
    
         
            -
                      raise 'Flipper::Middleware::Memoizer no longer initializes with a flipper instance or block. Read more at: https://git.io/vSo31.' # rubocop:disable LineLength
         
     | 
| 
      
 26 
     | 
    
         
            +
                      raise 'Flipper::Middleware::Memoizer no longer initializes with a flipper instance or block. Read more at: https://git.io/vSo31.' # rubocop:disable Layout/LineLength
         
     | 
| 
       27 
27 
     | 
    
         
             
                    end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                    @app = app
         
     | 
| 
         @@ -289,4 +289,19 @@ RSpec.shared_examples_for 'a flipper adapter' do 
     | 
|
| 
       289 
289 
     | 
    
         
             
                expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
         
     | 
| 
       290 
290 
     | 
    
         
             
                expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
         
     | 
| 
       291 
291 
     | 
    
         
             
              end
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
              it 'can get_all features when there are none' do
         
     | 
| 
      
 294 
     | 
    
         
            +
                expect(subject.features).to eq(Set.new)
         
     | 
| 
      
 295 
     | 
    
         
            +
                expect(subject.get_all).to eq({})
         
     | 
| 
      
 296 
     | 
    
         
            +
              end
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
              it 'clears other gate values on enable' do
         
     | 
| 
      
 299 
     | 
    
         
            +
                actor = Flipper::Actor.new('Flipper::Actor;22')
         
     | 
| 
      
 300 
     | 
    
         
            +
                subject.enable(feature, actors_gate, flipper.actors(25))
         
     | 
| 
      
 301 
     | 
    
         
            +
                subject.enable(feature, time_gate, flipper.time(25))
         
     | 
| 
      
 302 
     | 
    
         
            +
                subject.enable(feature, group_gate, flipper.group(:admins))
         
     | 
| 
      
 303 
     | 
    
         
            +
                subject.enable(feature, actor_gate, flipper.actor(actor))
         
     | 
| 
      
 304 
     | 
    
         
            +
                subject.enable(feature, boolean_gate, flipper.boolean(true))
         
     | 
| 
      
 305 
     | 
    
         
            +
                expect(subject.get(feature)).to eq(subject.default_config.merge(boolean: "true"))
         
     | 
| 
      
 306 
     | 
    
         
            +
              end
         
     | 
| 
       292 
307 
     | 
    
         
             
            end
         
     | 
| 
         @@ -285,6 +285,22 @@ module Flipper 
     | 
|
| 
       285 
285 
     | 
    
         
             
                    assert_equal true, @adapter.enable(@feature, @boolean_gate, @flipper.boolean)
         
     | 
| 
       286 
286 
     | 
    
         
             
                    assert_equal true, @adapter.enable(@feature, @boolean_gate, @flipper.boolean)
         
     | 
| 
       287 
287 
     | 
    
         
             
                  end
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
                  def test_can_get_all_features_when_there_are_none
         
     | 
| 
      
 290 
     | 
    
         
            +
                    expected = {}
         
     | 
| 
      
 291 
     | 
    
         
            +
                    assert_equal Set.new, @adapter.features
         
     | 
| 
      
 292 
     | 
    
         
            +
                    assert_equal expected, @adapter.get_all
         
     | 
| 
      
 293 
     | 
    
         
            +
                  end
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
                  def test_clears_other_gate_values_on_enable
         
     | 
| 
      
 296 
     | 
    
         
            +
                    actor = Flipper::Actor.new('Flipper::Actor;22')
         
     | 
| 
      
 297 
     | 
    
         
            +
                    assert_equal true, @adapter.enable(@feature, @actors_gate, @flipper.actors(25))
         
     | 
| 
      
 298 
     | 
    
         
            +
                    assert_equal true, @adapter.enable(@feature, @time_gate, @flipper.time(25))
         
     | 
| 
      
 299 
     | 
    
         
            +
                    assert_equal true, @adapter.enable(@feature, @group_gate, @flipper.group(:admins))
         
     | 
| 
      
 300 
     | 
    
         
            +
                    assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor))
         
     | 
| 
      
 301 
     | 
    
         
            +
                    assert_equal true, @adapter.enable(@feature, @boolean_gate, @flipper.boolean(true))
         
     | 
| 
      
 302 
     | 
    
         
            +
                    assert_equal @adapter.default_config.merge(boolean: "true"), @adapter.get(@feature)
         
     | 
| 
      
 303 
     | 
    
         
            +
                  end
         
     | 
| 
       288 
304 
     | 
    
         
             
                end
         
     | 
| 
       289 
305 
     | 
    
         
             
              end
         
     | 
| 
       290 
306 
     | 
    
         
             
            end
         
     | 
    
        data/lib/flipper/version.rb
    CHANGED
    
    
    
        data/spec/helper.rb
    CHANGED
    
    | 
         @@ -17,7 +17,7 @@ require 'flipper' 
     | 
|
| 
       17 
17 
     | 
    
         
             
            require 'flipper-ui'
         
     | 
| 
       18 
18 
     | 
    
         
             
            require 'flipper-api'
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            Dir[FlipperRoot.join('spec/support/**/*.rb')].each { |f| require f }
         
     | 
| 
      
 20 
     | 
    
         
            +
            Dir[FlipperRoot.join('spec/support/**/*.rb')].sort.each { |f| require f }
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            RSpec.configure do |config|
         
     | 
| 
       23 
23 
     | 
    
         
             
              config.before(:example) do
         
     | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        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.17. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.17.2
         
     | 
| 
       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: 2020-01-04 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: Feature flipper is the act of enabling/disabling features in your application,
         
     | 
| 
       14 
14 
     | 
    
         
             
              ideally without re-deploying or changing anything in your code base. Flipper makes
         
     |