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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 273cdc12fe558a68d730f16823c0359af205338e
4
- data.tar.gz: c81c4f77e24b81b7755bb6538e607781b28f0bcf
3
+ metadata.gz: 283755eb66ae51aea092b4f319bc5cb96cdd7d65
4
+ data.tar.gz: a4e4cf70364da4c3d79c27c8406f66965ad7ce8f
5
5
  SHA512:
6
- metadata.gz: 01b285fa1886ad10c2c9cbfd3d12f49ed1646eef8c1003747492c64643043803c233bff691df4d909d8d4896aed2068f755d73ec7109b5aa218e8406778dd85d
7
- data.tar.gz: 3b516946df426e50157ce113ef6e4d42de8cb49625b96d556d1ed238f009dd392247f5f6e93de1e7188e5247d72e6f210814b400bf2c3e0caf5c962f2665f02b
6
+ metadata.gz: 8aad1963c427983b0e351f1621770666d1a7d78dc90f8da58a2f66da9cea35b9113b836ea2db81bf449bed2a928e985217d22d4759110d00bcd4c79d74611a5c
7
+ data.tar.gz: b343b658390305a4fca98ff6928fc22291eca6eae738eb38a5def90c02301937df64960357eca48f2ba379a8dad4823c4e529d0b6d683a62b5604da517df42a6
data/LICENSE CHANGED
@@ -1,4 +1,5 @@
1
1
  Copyright (c) 2009 David Dollar
2
+ Copyright (c) 2012 - present Space Babies
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining
4
5
  a copy of this software and associated documentation files (the
@@ -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://www.codeship.io/projects/740db0a0-1a2c-0132-42f9-66434e25f59b/status" />}[https://www.codeship.io/projects/34562]
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
 
@@ -13,7 +13,8 @@ class Rack::Maintenance
13
13
 
14
14
  def call(env)
15
15
  if maintenance? && path_in_app(env)
16
- data = File.read(file)
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
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Maintenance
3
- VERSION = "2.0.1"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  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.1
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: 2015-09-14 00:00:00.000000000 Z
12
+ date: 2017-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack