rack-maintenance 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -0
- data/README.rdoc +13 -5
- data/lib/rack/maintenance/version.rb +1 -1
- data/lib/rack/maintenance.rb +7 -2
- data/spec/rack-maintenance_spec.rb +27 -1
- data/spec/unicode.html +13 -0
- metadata +46 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e7ae1d29d3548b2408d75ed5448791d2b0ad2495c09573b822d3d761e5e1c56
|
4
|
+
data.tar.gz: 81f58cd2d0e9980b6c52980390ad55bb591bbe5ee7a53d541d1886c70fa6609d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2742569f5de877db92511d930e763a26a3e98a0717b62d4d787b5b02327272c2de6f9faae4859ab748b1afc31ee074d57854cc3d67998cebfbe7faeef5d78a5a
|
7
|
+
data.tar.gz: 33ce46fd7d5480d5da8d95f97269331fec8bdb29330ba3ffe27b7007f1b6f8474a593091bd61562f44ef6f180e96679b1ed4e28b002415c35fd0240b21f73f1f
|
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
|
|
@@ -42,10 +50,6 @@ If <tt>:env</tt> is not specified, the maintenance page will be shown if it exis
|
|
42
50
|
:file => Rails.root.join('public', 'maintenance.html'),
|
43
51
|
:without => /\A\/assets/
|
44
52
|
|
45
|
-
If <tt>:paths</tt> is specified, only the paths specified in the given regular
|
46
|
-
expression will be put on maintenance mode. This is useful if you still want
|
47
|
-
access to an admin interface, as shown on the example.
|
48
|
-
|
49
53
|
== Note on Patches/Pull Requests
|
50
54
|
|
51
55
|
* Fork the project.
|
@@ -55,6 +59,10 @@ access to an admin interface, as shown on the example.
|
|
55
59
|
* Push your branch.
|
56
60
|
* Send me a pull request.
|
57
61
|
|
62
|
+
== Space Babies
|
63
|
+
|
64
|
+
We create internet. http://www.spacebabies.nl
|
65
|
+
|
58
66
|
== License
|
59
67
|
|
60
68
|
BSD. See LICENSE for details.
|
data/lib/rack/maintenance.rb
CHANGED
@@ -13,8 +13,9 @@ class Rack::Maintenance
|
|
13
13
|
|
14
14
|
def call(env)
|
15
15
|
if maintenance? && path_in_app(env)
|
16
|
-
|
17
|
-
|
16
|
+
content = File.read(file)
|
17
|
+
data = processor.call(content)
|
18
|
+
[ 503, { 'Content-Type' => content_type, 'Content-Length' => data.bytesize.to_s }, [data] ]
|
18
19
|
else
|
19
20
|
app.call(env)
|
20
21
|
end
|
@@ -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
|
@@ -4,6 +4,7 @@ require 'fileutils'
|
|
4
4
|
shared_examples "RackMaintenance" do
|
5
5
|
let(:app) { Class.new { def call(env); end }.new }
|
6
6
|
let(:rack) { Rack::Maintenance.new(app, :file => file_name) }
|
7
|
+
let(:data) { data = File.read(file_name) }
|
7
8
|
|
8
9
|
context "without a :file option" do
|
9
10
|
it "raises an error" do
|
@@ -14,6 +15,10 @@ shared_examples "RackMaintenance" do
|
|
14
15
|
end
|
15
16
|
|
16
17
|
context "without maintenance file" do
|
18
|
+
before do
|
19
|
+
FileUtils.rm(file_name) if File.exists?(file_name)
|
20
|
+
end
|
21
|
+
|
17
22
|
it "calls the app" do
|
18
23
|
app.should_receive(:call).once
|
19
24
|
rack.call({})
|
@@ -35,7 +40,7 @@ shared_examples "RackMaintenance" do
|
|
35
40
|
end
|
36
41
|
|
37
42
|
it "returns the maintenance response" do
|
38
|
-
rack.call({}).should eq [503, {"Content-Type"=>content_type, "Content-Length"=>
|
43
|
+
rack.call({}).should eq [503, {"Content-Type"=>content_type, "Content-Length"=>data.bytesize.to_s}, [data]]
|
39
44
|
end
|
40
45
|
|
41
46
|
context "and :env option MAINTENANCE" do
|
@@ -61,6 +66,18 @@ shared_examples "RackMaintenance" do
|
|
61
66
|
app.should_not_receive :call
|
62
67
|
rack.call({})
|
63
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
|
64
81
|
end
|
65
82
|
end
|
66
83
|
|
@@ -98,3 +115,12 @@ describe "RackMaintenance with html maintenance file" do
|
|
98
115
|
end
|
99
116
|
end
|
100
117
|
|
118
|
+
describe "RackMaintenance with unicode maintenance file" do
|
119
|
+
before do
|
120
|
+
FileUtils.cp 'spec/unicode.html', 'spec/maintenance.html'
|
121
|
+
end
|
122
|
+
it_behaves_like "RackMaintenance" do
|
123
|
+
let(:file_name) { "spec/maintenance.html" }
|
124
|
+
let(:content_type) { "text/html" }
|
125
|
+
end
|
126
|
+
end
|
data/spec/unicode.html
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Under Maintenance</title>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body>
|
9
|
+
<div class="dialog">
|
10
|
+
<h1>ขณะนี้กำลังอยู่ระหว่างการปรับปรุงระบบ</h1>
|
11
|
+
</div>
|
12
|
+
</body>
|
13
|
+
</html>
|
metadata
CHANGED
@@ -1,42 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-maintenance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Dollar
|
8
8
|
- Joost Baaij
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 2.1.4
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 2.1.4
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 12.3.3
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 12.3.3
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: rspec
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
|
-
- -
|
46
|
+
- - ">="
|
33
47
|
- !ruby/object:Gem::Version
|
34
48
|
version: '2.0'
|
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
55
|
version: '2.0'
|
42
56
|
description: Detect and show a maintenance page
|
@@ -47,18 +61,30 @@ executables: []
|
|
47
61
|
extensions: []
|
48
62
|
extra_rdoc_files: []
|
49
63
|
files:
|
50
|
-
- lib/rack/maintenance/version.rb
|
51
|
-
- lib/rack/maintenance.rb
|
52
|
-
- lib/rack-maintenance.rb
|
53
64
|
- LICENSE
|
54
|
-
- Rakefile
|
55
65
|
- README.rdoc
|
66
|
+
- Rakefile
|
67
|
+
- lib/rack-maintenance.rb
|
68
|
+
- lib/rack/maintenance.rb
|
69
|
+
- lib/rack/maintenance/version.rb
|
56
70
|
- spec/rack-maintenance_spec.rb
|
57
71
|
- spec/spec_helper.rb
|
72
|
+
- spec/unicode.html
|
58
73
|
homepage: http://github.com/tilsammans/rack-maintenance
|
59
74
|
licenses: []
|
60
75
|
metadata: {}
|
61
|
-
post_install_message:
|
76
|
+
post_install_message: |+
|
77
|
+
******** Rack::Maintenance 3.0.0 *********
|
78
|
+
|
79
|
+
This gem now requires rack version 2.1.4 or higher.
|
80
|
+
|
81
|
+
The reason for this change is that earlier versions have
|
82
|
+
security vulnerabilities. Because of this major change, I
|
83
|
+
took the time to require up-to-date versions of all
|
84
|
+
dependencies.
|
85
|
+
|
86
|
+
Rack::Maintenance 3.0.0 should be a drop-in upgrade.
|
87
|
+
|
62
88
|
|
63
89
|
******** Rack::Maintenance 2.0.0 *********
|
64
90
|
|
@@ -78,20 +104,21 @@ require_paths:
|
|
78
104
|
- lib
|
79
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
106
|
requirements:
|
81
|
-
- -
|
107
|
+
- - ">="
|
82
108
|
- !ruby/object:Gem::Version
|
83
109
|
version: '0'
|
84
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
111
|
requirements:
|
86
|
-
- -
|
112
|
+
- - ">="
|
87
113
|
- !ruby/object:Gem::Version
|
88
114
|
version: '0'
|
89
115
|
requirements: []
|
90
|
-
|
91
|
-
|
92
|
-
signing_key:
|
116
|
+
rubygems_version: 3.2.3
|
117
|
+
signing_key:
|
93
118
|
specification_version: 4
|
94
119
|
summary: Detect and show a maintenance page
|
95
120
|
test_files:
|
96
121
|
- spec/rack-maintenance_spec.rb
|
97
122
|
- spec/spec_helper.rb
|
123
|
+
- spec/unicode.html
|
124
|
+
...
|