rack-maintenance 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.rdoc +9 -1
- data/lib/rack/maintenance.rb +6 -1
- data/lib/rack/maintenance/version.rb +1 -1
- data/spec/rack-maintenance_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 283755eb66ae51aea092b4f319bc5cb96cdd7d65
|
4
|
+
data.tar.gz: a4e4cf70364da4c3d79c27c8406f66965ad7ce8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aad1963c427983b0e351f1621770666d1a7d78dc90f8da58a2f66da9cea35b9113b836ea2db81bf449bed2a928e985217d22d4759110d00bcd4c79d74611a5c
|
7
|
+
data.tar.gz: b343b658390305a4fca98ff6928fc22291eca6eae738eb38a5def90c02301937df64960357eca48f2ba379a8dad4823c4e529d0b6d683a62b5604da517df42a6
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Rack::Maintenance is a simple Rack middleware to detect the existence of a
|
4
4
|
maintenance page and display that instead of incoming requests.
|
5
5
|
|
6
|
-
{<img src="https://
|
6
|
+
{<img src="https://travis-ci.org/tilsammans/rack-maintenance.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/tilsammans/rack-maintenance]
|
7
7
|
|
8
8
|
== Installation
|
9
9
|
|
@@ -30,6 +30,14 @@ and then run `bundle`.
|
|
30
30
|
:file => Rails.root.join('public', 'maintenance.json'),
|
31
31
|
:env => 'MAINTENANCE'
|
32
32
|
|
33
|
+
# You may provide an object that responds to call to provide
|
34
|
+
# post-processing of the maintenance page such as merging
|
35
|
+
# ENV values into the page through ERB
|
36
|
+
config.middleware.use 'Rack::Maintenance',
|
37
|
+
:file => Rails.root.join('public', 'maintenance.html.erb'),
|
38
|
+
:env => 'MAINTENANCE',
|
39
|
+
:processor => lambda { |content| ERB.new(content).result }
|
40
|
+
|
33
41
|
If <tt>:env</tt> is specified, all requests will be shown the
|
34
42
|
maintenance page if the environment variable is set.
|
35
43
|
|
data/lib/rack/maintenance.rb
CHANGED
@@ -13,7 +13,8 @@ class Rack::Maintenance
|
|
13
13
|
|
14
14
|
def call(env)
|
15
15
|
if maintenance? && path_in_app(env)
|
16
|
-
|
16
|
+
content = File.read(file)
|
17
|
+
data = processor.call(content)
|
17
18
|
[ 503, { 'Content-Type' => content_type, 'Content-Length' => data.bytesize.to_s }, [data] ]
|
18
19
|
else
|
19
20
|
app.call(env)
|
@@ -34,6 +35,10 @@ private ######################################################################
|
|
34
35
|
options[:file]
|
35
36
|
end
|
36
37
|
|
38
|
+
def processor
|
39
|
+
options[:processor] || lambda { |content| content }
|
40
|
+
end
|
41
|
+
|
37
42
|
def maintenance?
|
38
43
|
environment ? ENV[environment] : File.exists?(file)
|
39
44
|
end
|
@@ -66,6 +66,18 @@ shared_examples "RackMaintenance" do
|
|
66
66
|
app.should_not_receive :call
|
67
67
|
rack.call({})
|
68
68
|
end
|
69
|
+
|
70
|
+
context "and :processor option" do
|
71
|
+
let(:processor) { lambda { |content| ERB.new(content).result } }
|
72
|
+
let(:rack) do
|
73
|
+
Rack::Maintenance.new(app, :file => file_name, :processor => processor )
|
74
|
+
end
|
75
|
+
|
76
|
+
it "passes the file content to the processor" do
|
77
|
+
processor.should_receive(:call).with(data).and_call_original
|
78
|
+
rack.call({})
|
79
|
+
end
|
80
|
+
end
|
69
81
|
end
|
70
82
|
end
|
71
83
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-maintenance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Dollar
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|