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 +4 -4
- data/lib/floodgate/version.rb +1 -1
- data/lib/floodgate.rb +6 -3
- data/spec/floodgate_spec.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd92ed8bca5cd54cc2257216a08d972fb94fac97
|
4
|
+
data.tar.gz: ef4911f7b3b5157311858f53b3d467257aef4839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fc5ed1de91f72b9fa1cc0f9d23d9ba1cf963d243749f8810120c0704c4c33d20be13b811e50741e9397202d1b362d1bfaff6fdc3bb40cc63d837975973b8b07
|
7
|
+
data.tar.gz: 2f43f2f36d0a0829900349c5ea2f36a1d9fdbab3d477afead0d2cb1b4ad329cee9999a0a46b8d3978a5eada4267ace8184e1974e4b8de232931456193504b908
|
data/lib/floodgate/version.rb
CHANGED
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
|
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
|
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 }, []]
|
data/spec/floodgate_spec.rb
CHANGED
@@ -13,8 +13,9 @@ module Floodgate
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when the floodgate is closed' do
|
16
|
-
|
17
|
-
|
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)
|