flipper-ui 0.7.0.beta4 → 0.7.0.beta5
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/docs/ui/README.md +12 -4
 - data/examples/ui/basic.ru +3 -1
 - data/lib/flipper/ui.rb +4 -5
 - data/lib/flipper/ui/actions/gate.rb +0 -1
 - data/lib/flipper/ui/middleware.rb +1 -1
 - data/lib/flipper/version.rb +1 -1
 - data/spec/flipper/ui/actions/actors_gate_spec.rb +0 -1
 - data/spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb +0 -1
 - data/spec/flipper/ui_spec.rb +3 -15
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ab0bcc2a79240d47bc81c5d1b07ac30ea036ccab
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e719e3fecef747f692140cff6bd7eb898d58bb83
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f648274c486d501453b90b82db87faa005483cd75b510a33fc7c41c2f4a7b4b2f19d6143576f12dc4b138389d4ddf016c2f4c8b6103d48706648447f3e9607ec
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 343d6b3558d012d8599760a358d75cd87461785326039a9cd9e864e8fb4ef39a12e45dc8eefc233b1c06e6ea1b5227bc0b1dc7718f8911269beb9b844a5ded34
         
     | 
    
        data/docs/ui/README.md
    CHANGED
    
    | 
         @@ -40,7 +40,7 @@ you can mount `Flipper::UI` to a route of your choice: 
     | 
|
| 
       40 
40 
     | 
    
         
             
            # config/routes.rb
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
            YourRailsApp::Application.routes.draw do
         
     | 
| 
       43 
     | 
    
         
            -
              mount Flipper::UI.app($flipper 
     | 
| 
      
 43 
     | 
    
         
            +
              mount Flipper::UI.app($flipper) => '/flipper'
         
     | 
| 
       44 
44 
     | 
    
         
             
            end
         
     | 
| 
       45 
45 
     | 
    
         
             
            ```
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
         @@ -53,7 +53,7 @@ You almost certainly want to limit access when using Flipper::UI in production. 
     | 
|
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
            flipper_constraint = lambda { |request| request.remote_ip == '127.0.0.1' }
         
     | 
| 
       55 
55 
     | 
    
         
             
            constraints flipper_constraint do
         
     | 
| 
       56 
     | 
    
         
            -
              mount Flipper::UI.app($flipper 
     | 
| 
      
 56 
     | 
    
         
            +
              mount Flipper::UI.app($flipper) => '/flipper'
         
     | 
| 
       57 
57 
     | 
    
         
             
            end
         
     | 
| 
       58 
58 
     | 
    
         
             
            ```
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
         @@ -72,7 +72,7 @@ end 
     | 
|
| 
       72 
72 
     | 
    
         
             
            # config/routes.rb
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
            constraints CanAccessFlipperUI do
         
     | 
| 
       75 
     | 
    
         
            -
              mount Flipper::UI.app($flipper 
     | 
| 
      
 75 
     | 
    
         
            +
              mount Flipper::UI.app($flipper) => '/flipper'
         
     | 
| 
       76 
76 
     | 
    
         
             
            end
         
     | 
| 
       77 
77 
     | 
    
         
             
            ```
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
         @@ -90,7 +90,15 @@ require 'flipper/adapters/memory' 
     | 
|
| 
       90 
90 
     | 
    
         
             
            adapter = Flipper::Adapters::Memory.new
         
     | 
| 
       91 
91 
     | 
    
         
             
            flipper = Flipper.new(adapter)
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
            run Flipper::UI.app(flipper 
     | 
| 
      
 93 
     | 
    
         
            +
            run Flipper::UI.app(flipper) { |builder|
         
     | 
| 
      
 94 
     | 
    
         
            +
              builder.use Rack::Session::Cookie, secret: "something long and random"
         
     | 
| 
      
 95 
     | 
    
         
            +
            }
         
     | 
| 
      
 96 
     | 
    
         
            +
            ```
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
            The key is that you need to have sessions setup. Rails does this for you, so this step isn't necessary, but for standalone rack, you'll need it. Without sessions setup, you will receive a Runtime error like:
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            ```
         
     | 
| 
      
 101 
     | 
    
         
            +
            RuntimeError: you need to set up a session middleware *before* Rack::Protection::RemoteToken.
         
     | 
| 
       94 
102 
     | 
    
         
             
            ```
         
     | 
| 
       95 
103 
     | 
    
         | 
| 
       96 
104 
     | 
    
         
             
            See [examples/ui/basic.ru](https://github.com/jnunemaker/flipper/blob/master/examples/ui/basic.ru) for a more full example
         
     | 
    
        data/examples/ui/basic.ru
    CHANGED
    
    | 
         @@ -43,4 +43,6 @@ flipper = Flipper.new(adapter, instrumenter: ActiveSupport::Notifications) 
     | 
|
| 
       43 
43 
     | 
    
         
             
            # flipper[:logging].enable_percentage_of_time 5
         
     | 
| 
       44 
44 
     | 
    
         
             
            # flipper[:new_cache].enable_percentage_of_actors 15
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
            run Flipper::UI.app(flipper 
     | 
| 
      
 46 
     | 
    
         
            +
            run Flipper::UI.app(flipper) { |builder|
         
     | 
| 
      
 47 
     | 
    
         
            +
              builder.use Rack::Session::Cookie, secret: "_super_secret"
         
     | 
| 
      
 48 
     | 
    
         
            +
            }
         
     | 
    
        data/lib/flipper/ui.rb
    CHANGED
    
    | 
         @@ -2,9 +2,13 @@ require 'pathname' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'rack'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'rack/methodoverride'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'rack/protection'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       5 
6 
     | 
    
         
             
            require 'flipper'
         
     | 
| 
       6 
7 
     | 
    
         
             
            require 'flipper/middleware/memoizer'
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
            require 'flipper/ui/actor'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'flipper/ui/middleware'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       8 
12 
     | 
    
         
             
            module Flipper
         
     | 
| 
       9 
13 
     | 
    
         
             
              module UI
         
     | 
| 
       10 
14 
     | 
    
         
             
                def self.root
         
     | 
| 
         @@ -15,8 +19,6 @@ module Flipper 
     | 
|
| 
       15 
19 
     | 
    
         
             
                  app = lambda { |env| [200, {'Content-Type' => 'text/html'}, ['']] }
         
     | 
| 
       16 
20 
     | 
    
         
             
                  builder = Rack::Builder.new
         
     | 
| 
       17 
21 
     | 
    
         
             
                  yield builder if block_given?
         
     | 
| 
       18 
     | 
    
         
            -
                  secret = options[:secret] || raise(ArgumentError, "Flipper::UI.app missing required option: secret")
         
     | 
| 
       19 
     | 
    
         
            -
                  builder.use Rack::Session::Cookie, secret: secret
         
     | 
| 
       20 
22 
     | 
    
         
             
                  builder.use Rack::Protection
         
     | 
| 
       21 
23 
     | 
    
         
             
                  builder.use Rack::Protection::AuthenticityToken
         
     | 
| 
       22 
24 
     | 
    
         
             
                  builder.use Rack::MethodOverride
         
     | 
| 
         @@ -27,6 +29,3 @@ module Flipper 
     | 
|
| 
       27 
29 
     | 
    
         
             
                end
         
     | 
| 
       28 
30 
     | 
    
         
             
              end
         
     | 
| 
       29 
31 
     | 
    
         
             
            end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            require 'flipper/ui/middleware'
         
     | 
| 
       32 
     | 
    
         
            -
            require 'flipper/ui/actor'
         
     | 
| 
         @@ -2,7 +2,7 @@ require 'rack' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'flipper/ui/action_collection'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            # Require all actions automatically.
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            Pathname(__FILE__).dirname.join('actions').each_child(false) do |name|
         
     | 
| 
       6 
6 
     | 
    
         
             
              require "flipper/ui/actions/#{name}"
         
     | 
| 
       7 
7 
     | 
    
         
             
            end
         
     | 
| 
       8 
8 
     | 
    
         | 
    
        data/lib/flipper/version.rb
    CHANGED
    
    
    
        data/spec/flipper/ui_spec.rb
    CHANGED
    
    | 
         @@ -1,14 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'rack/test'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'flipper'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'flipper/adapters/memory'
         
     | 
| 
       5 
2 
     | 
    
         | 
| 
       6 
3 
     | 
    
         
             
            describe Flipper::UI do
         
     | 
| 
       7 
     | 
    
         
            -
              include Rack::Test::Methods
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              let(:flipper) { build_flipper }
         
     | 
| 
       10 
     | 
    
         
            -
              let(:app)     { build_app(flipper) }
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
4 
     | 
    
         
             
              describe "Initializing middleware with flipper instance" do
         
     | 
| 
       13 
5 
     | 
    
         
             
                let(:app) { build_app(flipper) }
         
     | 
| 
       14 
6 
     | 
    
         | 
| 
         @@ -21,7 +13,9 @@ describe Flipper::UI do 
     | 
|
| 
       21 
13 
     | 
    
         
             
              end
         
     | 
| 
       22 
14 
     | 
    
         | 
| 
       23 
15 
     | 
    
         
             
              describe "Initializing middleware lazily with a block" do
         
     | 
| 
       24 
     | 
    
         
            -
                let(:app) { 
     | 
| 
      
 16 
     | 
    
         
            +
                let(:app) {
         
     | 
| 
      
 17 
     | 
    
         
            +
                  build_app(lambda { flipper })
         
     | 
| 
      
 18 
     | 
    
         
            +
                }
         
     | 
| 
       25 
19 
     | 
    
         | 
| 
       26 
20 
     | 
    
         
             
                it "works" do
         
     | 
| 
       27 
21 
     | 
    
         
             
                  flipper.enable :some_great_feature
         
     | 
| 
         @@ -31,12 +25,6 @@ describe Flipper::UI do 
     | 
|
| 
       31 
25 
     | 
    
         
             
                end
         
     | 
| 
       32 
26 
     | 
    
         
             
              end
         
     | 
| 
       33 
27 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
              describe "Creating app without secret" do
         
     | 
| 
       35 
     | 
    
         
            -
                it "raises argument error" do
         
     | 
| 
       36 
     | 
    
         
            -
                  expect { Flipper::UI.app(flipper) }.to raise_error(ArgumentError, "Flipper::UI.app missing required option: secret")
         
     | 
| 
       37 
     | 
    
         
            -
                end
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
28 
     | 
    
         
             
              describe "Request method unsupported by action" do
         
     | 
| 
       41 
29 
     | 
    
         
             
                it "raises error" do
         
     | 
| 
       42 
30 
     | 
    
         
             
                  expect {
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: flipper-ui
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.7.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.7.0.beta5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - John Nunemaker
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-04-29 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rack
         
     | 
| 
         @@ -50,14 +50,14 @@ dependencies: 
     | 
|
| 
       50 
50 
     | 
    
         
             
                requirements:
         
     | 
| 
       51 
51 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       52 
52 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       53 
     | 
    
         
            -
                    version: 0.7.0. 
     | 
| 
      
 53 
     | 
    
         
            +
                    version: 0.7.0.beta5
         
     | 
| 
       54 
54 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       55 
55 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       56 
56 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       57 
57 
     | 
    
         
             
                requirements:
         
     | 
| 
       58 
58 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       59 
59 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       60 
     | 
    
         
            -
                    version: 0.7.0. 
     | 
| 
      
 60 
     | 
    
         
            +
                    version: 0.7.0.beta5
         
     | 
| 
       61 
61 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       62 
62 
     | 
    
         
             
              name: erubis
         
     | 
| 
       63 
63 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |