floodgate 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ae4c9182d4f9b6938b6d4abac5bbde71f2bda85
4
- data.tar.gz: c6b0255e7ee3be470608a02d735c67817fcaa63c
3
+ metadata.gz: bd92ed8bca5cd54cc2257216a08d972fb94fac97
4
+ data.tar.gz: ef4911f7b3b5157311858f53b3d467257aef4839
5
5
  SHA512:
6
- metadata.gz: 6a9cb226da8d6176737b87d83bef67274c7f7c5609ad29f2ad9d6c856aa88c43d6d9fd2bb850aaf4872b3da8c0a14f585e588eb60bb711cf50bb3f33a1f2ce44
7
- data.tar.gz: 31e187612db38471718a985823429a73289b5eba08f3229778d61cc8589203ae0198ceb69d8a2e532421690da712b69681da5d20de665c001e55771492c53843
6
+ metadata.gz: 7fc5ed1de91f72b9fa1cc0f9d23d9ba1cf963d243749f8810120c0704c4c33d20be13b811e50741e9397202d1b362d1bfaff6fdc3bb40cc63d837975973b8b07
7
+ data.tar.gz: 2f43f2f36d0a0829900349c5ea2f36a1d9fdbab3d477afead0d2cb1b4ad329cee9999a0a46b8d3978a5eada4267ace8184e1974e4b8de232931456193504b908
@@ -1,3 +1,3 @@
1
1
  module Floodgate
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/floodgate.rb CHANGED
@@ -2,13 +2,16 @@ require 'floodgate/version'
2
2
 
3
3
  module Floodgate
4
4
  class Control
5
- def initialize(app, filter_traffic=false)
6
- @filter_traffic = filter_traffic
5
+ def initialize(app)
7
6
  @app = app
8
7
  end
9
8
 
9
+ def filter_traffic?(env)
10
+ !env['FLOODGATE_FILTER_TRAFFIC'].nil?
11
+ end
12
+
10
13
  def call(env)
11
- return @app.call(env) unless @filter_traffic
14
+ return @app.call(env) unless filter_traffic?(env)
12
15
 
13
16
  if maintenance_url = env['MAINTENANCE_PAGE_URL']
14
17
  [307, { 'Location' => maintenance_url }, []]
@@ -13,8 +13,9 @@ module Floodgate
13
13
  end
14
14
 
15
15
  context 'when the floodgate is closed' do
16
- let(:filter_traffic) { true }
17
- let(:control) { described_class.new(app, filter_traffic) }
16
+ before { env['FLOODGATE_FILTER_TRAFFIC'] = 'closed' }
17
+
18
+ let(:control) { described_class.new(app) }
18
19
 
19
20
  it 'does not send :call to the app' do
20
21
  expect(app).not_to receive(:call).with(env)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: floodgate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark McEahern