rack-maintenance 0.3.0 → 1.0.0
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.
- data/README.rdoc +10 -0
- data/Rakefile +3 -41
- data/lib/rack-maintenance.rb +1 -0
- data/lib/rack/maintenance.rb +5 -1
- data/lib/rack/maintenance/version.rb +5 -0
- data/spec/rack-maintenance_spec.rb +65 -2
- data/spec/spec_helper.rb +8 -7
- metadata +65 -70
- data/.document +0 -5
- data/.gitignore +0 -5
- data/VERSION +0 -1
- data/rack-maintenance.gemspec +0 -59
data/README.rdoc
CHANGED
@@ -3,10 +3,20 @@
|
|
3
3
|
Rack::Maintenance is a simple Rack middleware to detect the existence of a
|
4
4
|
maintenance.html page and display that instead of incoming requests.
|
5
5
|
|
6
|
+
{<img src="https://secure.travis-ci.org/tilsammans/rack-maintenance.png" />}[http://travis-ci.org/tilsammans/rack-maintenance]
|
7
|
+
|
6
8
|
== Installation
|
7
9
|
|
8
10
|
sudo gem install rack-maintenance
|
9
11
|
|
12
|
+
== Installation with Bundler
|
13
|
+
|
14
|
+
In Gemfile:
|
15
|
+
|
16
|
+
gem 'rack-maintenance'
|
17
|
+
|
18
|
+
and then run `bundle`.
|
19
|
+
|
10
20
|
== Usage
|
11
21
|
|
12
22
|
# config/environment.rb
|
data/Rakefile
CHANGED
@@ -1,45 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require 'rake'
|
1
|
+
require "bundler/gem_tasks"
|
3
2
|
|
4
|
-
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "rack-maintenance"
|
8
|
-
gem.summary = %Q{Detect and show a maintenance page}
|
9
|
-
gem.description = gem.summary
|
10
|
-
gem.email = "<ddollar@gmail.com>"
|
11
|
-
gem.homepage = "http://github.com/ddollar/rack-maintenance"
|
12
|
-
gem.authors = ["David Dollar"]
|
13
|
-
gem.add_development_dependency "rspec"
|
14
|
-
gem.add_development_dependency "yard"
|
15
|
-
gem.add_dependency 'rack', '>= 1.0'
|
16
|
-
end
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
-
end
|
3
|
+
require "rspec/core/rake_task"
|
21
4
|
|
22
|
-
|
23
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
-
spec.libs << 'lib' << 'spec'
|
25
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
-
end
|
27
|
-
|
28
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
-
spec.libs << 'lib' << 'spec'
|
30
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
-
spec.rcov = true
|
32
|
-
end
|
33
|
-
|
34
|
-
task :spec => :check_dependencies
|
5
|
+
RSpec::Core::RakeTask.new('spec')
|
35
6
|
|
36
7
|
task :default => :spec
|
37
|
-
|
38
|
-
begin
|
39
|
-
require 'yard'
|
40
|
-
YARD::Rake::YardocTask.new
|
41
|
-
rescue LoadError
|
42
|
-
task :yardoc do
|
43
|
-
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
44
|
-
end
|
45
|
-
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rack/maintenance'
|
data/lib/rack/maintenance.rb
CHANGED
@@ -12,7 +12,7 @@ class Rack::Maintenance
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(env)
|
15
|
-
if maintenance?
|
15
|
+
if maintenance? && path_in_app(env)
|
16
16
|
data = File.read(file)
|
17
17
|
[ 503, { 'Content-Type' => 'text/html', 'Content-Length' => data.length.to_s }, [data] ]
|
18
18
|
else
|
@@ -34,4 +34,8 @@ private ######################################################################
|
|
34
34
|
environment ? ENV[environment] : File.exists?(file)
|
35
35
|
end
|
36
36
|
|
37
|
+
def path_in_app(env)
|
38
|
+
env["PATH_INFO"] !~ /^\/assets/
|
39
|
+
end
|
40
|
+
|
37
41
|
end
|
@@ -1,7 +1,70 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
describe "RackMaintenance" do
|
4
|
-
|
5
|
-
|
5
|
+
let(:app) { Class.new { def call(env); end }.new }
|
6
|
+
let(:rack) { Rack::Maintenance.new(app, :file => "spec/maintenance.html") }
|
7
|
+
|
8
|
+
context "without a :file option" do
|
9
|
+
it "raises an error" do
|
10
|
+
expect {
|
11
|
+
Rack::Maintenance.new(app)
|
12
|
+
}.to raise_error(ArgumentError)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "without maintenance file" do
|
17
|
+
it "calls the app" do
|
18
|
+
app.should_receive(:call).once
|
19
|
+
rack.call({})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with maintenance file" do
|
24
|
+
before do
|
25
|
+
FileUtils.touch 'spec/maintenance.html'
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
FileUtils.rm 'spec/maintenance.html'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "does not call the app" do
|
33
|
+
app.should_not_receive :call
|
34
|
+
rack.call({})
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns the maintenance response" do
|
38
|
+
rack.call({}).should eq [503, {"Content-Type"=>"text/html", "Content-Length"=>"0"}, [""]]
|
39
|
+
end
|
40
|
+
|
41
|
+
context "and :env option MAINTENANCE" do
|
42
|
+
let(:rack) { Rack::Maintenance.new(app, :file => "spec/maintenance.html", :env => "MAINTENANCE") }
|
43
|
+
|
44
|
+
context "outside MAINTENANCE env" do
|
45
|
+
it "calls the app" do
|
46
|
+
app.should_receive(:call).once
|
47
|
+
rack.call({})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "inside MAINTENANCE env" do
|
52
|
+
before do
|
53
|
+
ENV['MAINTENANCE'] = "true"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "does not call the app" do
|
57
|
+
app.should_not_receive :call
|
58
|
+
rack.call({})
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "and request to /assets" do
|
64
|
+
it "calls the app" do
|
65
|
+
app.should_receive(:call).once
|
66
|
+
rack.call({"PATH_INFO"=>"/assets/application.css"})
|
67
|
+
end
|
68
|
+
end
|
6
69
|
end
|
7
70
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rack-maintenance'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
6
3
|
|
7
|
-
|
8
|
-
|
4
|
+
require 'rack/maintenance'
|
5
|
+
|
6
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# some optional config here
|
9
10
|
end
|
metadata
CHANGED
@@ -1,95 +1,90 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-maintenance
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- David Dollar
|
9
|
+
- Joost Baaij
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: rspec
|
17
|
-
type: :development
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: yard
|
27
|
-
type: :development
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
36
16
|
name: rack
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.0'
|
37
23
|
type: :runtime
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rspec
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
45
47
|
description: Detect and show a maintenance page
|
46
|
-
email:
|
48
|
+
email:
|
49
|
+
- ddollar@gmail.com
|
50
|
+
- joost@spacebabies.nl
|
47
51
|
executables: []
|
48
|
-
|
49
52
|
extensions: []
|
50
|
-
|
51
|
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
|
55
|
-
- .document
|
56
|
-
- .gitignore
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- lib/rack/maintenance/version.rb
|
56
|
+
- lib/rack/maintenance.rb
|
57
|
+
- lib/rack-maintenance.rb
|
57
58
|
- LICENSE
|
58
|
-
- README.rdoc
|
59
59
|
- Rakefile
|
60
|
-
-
|
61
|
-
- lib/rack/maintenance.rb
|
62
|
-
- rack-maintenance.gemspec
|
60
|
+
- README.rdoc
|
63
61
|
- spec/rack-maintenance_spec.rb
|
64
62
|
- spec/spec_helper.rb
|
65
|
-
|
66
|
-
homepage: http://github.com/ddollar/rack-maintenance
|
63
|
+
homepage: http://github.com/tilsammans/rack-maintenance
|
67
64
|
licenses: []
|
68
|
-
|
69
65
|
post_install_message:
|
70
|
-
rdoc_options:
|
71
|
-
|
72
|
-
require_paths:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
73
68
|
- lib
|
74
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
86
81
|
requirements: []
|
87
|
-
|
88
82
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.8.23
|
90
84
|
signing_key:
|
91
85
|
specification_version: 3
|
92
86
|
summary: Detect and show a maintenance page
|
93
|
-
test_files:
|
87
|
+
test_files:
|
94
88
|
- spec/rack-maintenance_spec.rb
|
95
89
|
- spec/spec_helper.rb
|
90
|
+
has_rdoc:
|
data/.document
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.0
|
data/rack-maintenance.gemspec
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{rack-maintenance}
|
8
|
-
s.version = "0.3.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["David Dollar"]
|
12
|
-
s.date = %q{2009-08-31}
|
13
|
-
s.description = %q{Detect and show a maintenance page}
|
14
|
-
s.email = %q{<ddollar@gmail.com>}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/rack/maintenance.rb",
|
27
|
-
"rack-maintenance.gemspec",
|
28
|
-
"spec/rack-maintenance_spec.rb",
|
29
|
-
"spec/spec_helper.rb"
|
30
|
-
]
|
31
|
-
s.homepage = %q{http://github.com/ddollar/rack-maintenance}
|
32
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
-
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = %q{1.3.5}
|
35
|
-
s.summary = %q{Detect and show a maintenance page}
|
36
|
-
s.test_files = [
|
37
|
-
"spec/rack-maintenance_spec.rb",
|
38
|
-
"spec/spec_helper.rb"
|
39
|
-
]
|
40
|
-
|
41
|
-
if s.respond_to? :specification_version then
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
-
s.specification_version = 3
|
44
|
-
|
45
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
47
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
48
|
-
s.add_runtime_dependency(%q<rack>, [">= 1.0"])
|
49
|
-
else
|
50
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
51
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
52
|
-
s.add_dependency(%q<rack>, [">= 1.0"])
|
53
|
-
end
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
57
|
-
s.add_dependency(%q<rack>, [">= 1.0"])
|
58
|
-
end
|
59
|
-
end
|