rack_maintenance 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9c9e9d88f41cfabf75bb1e08cd6a4b370430cf8
4
+ data.tar.gz: 91b50ad6cf4bd6c1b10fb9d636d978f610741e3c
5
+ SHA512:
6
+ metadata.gz: c6d1675516e899f16c3760078e4266f07160cca752585ea8cbb4c52322d796e8a9d8b72fe44678c5f0ec8b73205b2a9a26cad02820c7b66352a01abc3483f989
7
+ data.tar.gz: 4e312e74110ea3fcccee992d15dceea32808476bebd25df3787cdc1473ba2154e9646f479dfd14426920b50f8ebff008b6a31eb7812975b5c84879fbbba2fddd
@@ -0,0 +1,48 @@
1
+ module Rack
2
+ class Maintenance
3
+
4
+ class InvalidStatus < StandardError; end
5
+
6
+ def initialize(app, options = {})
7
+
8
+ raise InvalidStatus if options[:status] && options[:status].to_i < 100
9
+
10
+ @app = app
11
+ @status = options[:status] || default_status
12
+ @headers = options[:headers] || default_headers
13
+ @template = options[:template] || default_template
14
+ @active = options[:active].nil? ? true : options[:active]
15
+ end
16
+
17
+ def call(env)
18
+ if active?
19
+ headers['Content-Length'] = body.bytesize.to_s
20
+ return [status, headers, [body]]
21
+ end
22
+
23
+ @app.call(env)
24
+ end
25
+
26
+ private
27
+ attr_reader :status, :headers, :template, :active
28
+
29
+ alias body template
30
+
31
+ def default_status
32
+ 503
33
+ end
34
+
35
+ def default_headers
36
+ {'Content-Type'=> 'text/html'}
37
+ end
38
+
39
+ def default_template
40
+ "<h2>Sorry. We're under maintenance...<h2>"
41
+ end
42
+
43
+ def active?
44
+ !!@active
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1 @@
1
+ require 'rack/maintenance'
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "rack_maintenance"
3
+ s.version = "0.1.0"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.summary = "Rack middleware to show maintenance page"
6
+ s.license = "MIT"
7
+
8
+ s.description = <<-EOF
9
+ It provide maintenance page to your rack application.
10
+ Also see https://github.com/borot/rack_maintenance.
11
+ EOF
12
+
13
+ s.files = Dir['{lib/**/*, spec/*}'] +
14
+ %w(rack_maintenance.gemspec )
15
+ s.require_path = 'lib'
16
+
17
+ s.author = 'Masato Ishimoto'
18
+ s.email = 'masato.ishimoto@gmail.com'
19
+ s.homepage = 'https://github.com/borot/rack_maintenance'
20
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack_maintenance
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masato Ishimoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ It provide maintenance page to your rack application.
15
+ Also see https://github.com/borot/rack_maintenance.
16
+ email: masato.ishimoto@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/rack/maintenance.rb
22
+ - lib/rack_maintenance.rb
23
+ - rack_maintenance.gemspec
24
+ homepage: https://github.com/borot/rack_maintenance
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.0.3
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Rack middleware to show maintenance page
48
+ test_files: []