heroku_header 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +26 -2
- data/lib/heroku_header/middle_ware.rb +2 -2
- data/lib/heroku_header/version.rb +1 -1
- data/spec/middle_ware_spec.rb +8 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# HerokuHeader
|
2
2
|
|
3
|
-
|
3
|
+
Rack middleware that will insert Heroku's navigation header on a specified subdomain.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,31 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
`HerokuHeader::MiddleWare` takes a few config options, all optional:
|
22
|
+
|
23
|
+
* `:subdomain` => The subdomain to show the header on, defaults to `heroku`.
|
24
|
+
* `:timeout` => How many seconds until the request to get the header is cancelled, default is 5. (It fails silently when it can't fetch the header).
|
25
|
+
* `:cache` => This expects an object which conforms to the `ActiveSupport::Cache::Store` API. It is not reccomended to leave this out, in which case the header will be fetched from Heroku on each request (when required).
|
26
|
+
* `:cache_key` => This is the key which is used to store and retrieve the header from `:cache`. Defaults to 'heroku_header_html'.
|
27
|
+
|
28
|
+
### Rails
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# application.rb
|
32
|
+
config.middleware.use HerokuHeader::MiddleWare, :subdomain => 'heroku', :timeout => 5, :cache => lambda { Rails.cache }
|
33
|
+
```
|
34
|
+
|
35
|
+
### Sinatra
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'sinatra'
|
39
|
+
|
40
|
+
use HerokuHeader::MiddleWare, :subdomain => 'heroku', :timeout => 5
|
41
|
+
|
42
|
+
get '/' do
|
43
|
+
....
|
44
|
+
end
|
45
|
+
```
|
22
46
|
|
23
47
|
## Contributing
|
24
48
|
|
@@ -28,7 +28,7 @@ module HerokuHeader
|
|
28
28
|
|
29
29
|
private
|
30
30
|
def html_response?
|
31
|
-
@headers['Content-Type'].include?('text/html')
|
31
|
+
@headers['Content-Type'] && @headers['Content-Type'].include?('text/html')
|
32
32
|
end
|
33
33
|
|
34
34
|
def heroku_subdomain?
|
@@ -76,4 +76,4 @@ module HerokuHeader
|
|
76
76
|
end
|
77
77
|
|
78
78
|
end
|
79
|
-
end
|
79
|
+
end
|
data/spec/middle_ware_spec.rb
CHANGED
@@ -54,6 +54,13 @@ describe HerokuHeader::MiddleWare do
|
|
54
54
|
@heroku_header.send(:html_response?).should be_false
|
55
55
|
end
|
56
56
|
|
57
|
+
it "should not crash if Content-Type is nil" do
|
58
|
+
@heroku_header.instance_variable_set(:@headers, {})
|
59
|
+
lambda {
|
60
|
+
@heroku_header.send(:html_response?)
|
61
|
+
}.should_not raise_error
|
62
|
+
end
|
63
|
+
|
57
64
|
end
|
58
65
|
|
59
66
|
context "inserting the header" do
|
@@ -82,4 +89,4 @@ describe HerokuHeader::MiddleWare do
|
|
82
89
|
|
83
90
|
end
|
84
91
|
|
85
|
-
end
|
92
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku_header
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
segments:
|
110
110
|
- 0
|
111
|
-
hash:
|
111
|
+
hash: -2037551427770845354
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
segments:
|
119
119
|
- 0
|
120
|
-
hash:
|
120
|
+
hash: -2037551427770845354
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
123
|
rubygems_version: 1.8.23
|