floodgate 0.0.1 → 0.0.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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Rakefile +6 -1
- data/floodgate.gemspec +2 -1
- data/lib/floodgate/version.rb +1 -1
- data/lib/floodgate.rb +17 -2
- data/spec/floodgate_spec.rb +48 -0
- data/spec/spec_helper.rb +17 -0
- metadata +30 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ae4c9182d4f9b6938b6d4abac5bbde71f2bda85
|
4
|
+
data.tar.gz: c6b0255e7ee3be470608a02d735c67817fcaa63c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a9cb226da8d6176737b87d83bef67274c7f7c5609ad29f2ad9d6c856aa88c43d6d9fd2bb850aaf4872b3da8c0a14f585e588eb60bb711cf50bb3f33a1f2ce44
|
7
|
+
data.tar.gz: 31e187612db38471718a985823429a73289b5eba08f3229778d61cc8589203ae0198ceb69d8a2e532421690da712b69681da5d20de665c001e55771492c53843
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
floodgate
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p353
|
data/Rakefile
CHANGED
data/floodgate.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
21
|
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec', '~> 2.14'
|
23
|
+
spec.add_development_dependency 'simplecov', '~> 0.8'
|
23
24
|
end
|
data/lib/floodgate/version.rb
CHANGED
data/lib/floodgate.rb
CHANGED
@@ -1,5 +1,20 @@
|
|
1
|
-
require
|
1
|
+
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
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
return @app.call(env) unless @filter_traffic
|
12
|
+
|
13
|
+
if maintenance_url = env['MAINTENANCE_PAGE_URL']
|
14
|
+
[307, { 'Location' => maintenance_url }, []]
|
15
|
+
else
|
16
|
+
[503, {}, ['Application Unavailable']]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
5
20
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Floodgate
|
4
|
+
describe Control do
|
5
|
+
let(:app) { double().as_null_object }
|
6
|
+
let(:control) { described_class.new(app) }
|
7
|
+
let(:env) { Hash.new }
|
8
|
+
|
9
|
+
describe '#call' do
|
10
|
+
it 'sends :call to the app with the specified environment' do
|
11
|
+
expect(app).to receive(:call).with(env)
|
12
|
+
control.call(env)
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when the floodgate is closed' do
|
16
|
+
let(:filter_traffic) { true }
|
17
|
+
let(:control) { described_class.new(app, filter_traffic) }
|
18
|
+
|
19
|
+
it 'does not send :call to the app' do
|
20
|
+
expect(app).not_to receive(:call).with(env)
|
21
|
+
control.call(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when a maintenance page is specified in the environment' do
|
25
|
+
before { env['MAINTENANCE_PAGE_URL'] = 'someurl' }
|
26
|
+
|
27
|
+
it 'redirects with a temporary redirect status' do
|
28
|
+
expect(control.call(env)[0]).to eq(307)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'has a location set to the maintenance page' do
|
32
|
+
expect(control.call(env)[1]['Location']).to eq('someurl')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when no maintenance page is specified in the environment' do
|
37
|
+
it 'responds with a status of service unavailable' do
|
38
|
+
expect(control.call(env)[0]).to eq(503)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'has an appropriate message in the response' do
|
42
|
+
expect(control.call(env)[2]).to eq(['Application Unavailable'])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter '/spec/'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rspec'
|
8
|
+
|
9
|
+
require 'floodgate'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.filter_run focused: true
|
14
|
+
config.alias_example_to :fit, focused: true
|
15
|
+
config.alias_example_to :pit, pending: true
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
end
|
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.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark McEahern
|
@@ -12,33 +12,47 @@ cert_chain: []
|
|
12
12
|
date: 2014-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
17
31
|
requirements:
|
18
32
|
- - ~>
|
19
33
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
34
|
+
version: '2.14'
|
21
35
|
type: :development
|
22
36
|
prerelease: false
|
23
37
|
version_requirements: !ruby/object:Gem::Requirement
|
24
38
|
requirements:
|
25
39
|
- - ~>
|
26
40
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
41
|
+
version: '2.14'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
43
|
+
name: simplecov
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
|
-
- -
|
46
|
+
- - ~>
|
33
47
|
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
48
|
+
version: '0.8'
|
35
49
|
type: :development
|
36
50
|
prerelease: false
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
|
-
- -
|
53
|
+
- - ~>
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
55
|
+
version: '0.8'
|
42
56
|
description: floodgate helps you control access to your app
|
43
57
|
email:
|
44
58
|
- mark@adorable.io
|
@@ -48,6 +62,8 @@ extensions: []
|
|
48
62
|
extra_rdoc_files: []
|
49
63
|
files:
|
50
64
|
- .gitignore
|
65
|
+
- .ruby-gemset
|
66
|
+
- .ruby-version
|
51
67
|
- Gemfile
|
52
68
|
- LICENSE.txt
|
53
69
|
- README.md
|
@@ -55,6 +71,8 @@ files:
|
|
55
71
|
- floodgate.gemspec
|
56
72
|
- lib/floodgate.rb
|
57
73
|
- lib/floodgate/version.rb
|
74
|
+
- spec/floodgate_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
58
76
|
homepage: http://github.com/adorableio/floodgate
|
59
77
|
licenses:
|
60
78
|
- MIT
|
@@ -79,4 +97,6 @@ rubygems_version: 2.1.11
|
|
79
97
|
signing_key:
|
80
98
|
specification_version: 4
|
81
99
|
summary: floodgate helps you control access to your app
|
82
|
-
test_files:
|
100
|
+
test_files:
|
101
|
+
- spec/floodgate_spec.rb
|
102
|
+
- spec/spec_helper.rb
|