heroku-nav 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/heroku-nav.gemspec +1 -1
- data/lib/heroku/nav.rb +5 -5
- data/spec/nav_spec.rb +17 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -21,8 +21,8 @@ begin
|
|
21
21
|
gemspec.add_dependency(%q<rest-client>, ["~> 1.2.0"])
|
22
22
|
gemspec.add_dependency(%q<json>, [">= 0"])
|
23
23
|
|
24
|
-
gemspec.version = '0.1.
|
24
|
+
gemspec.version = '0.1.3'
|
25
25
|
end
|
26
26
|
rescue LoadError
|
27
27
|
puts "Jeweler not available. Install it with: gem install jeweler"
|
28
|
-
end
|
28
|
+
end
|
data/heroku-nav.gemspec
CHANGED
data/lib/heroku/nav.rb
CHANGED
@@ -6,9 +6,9 @@ module Heroku
|
|
6
6
|
class Base
|
7
7
|
def initialize(app, options={})
|
8
8
|
@app = app
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
@options = options
|
10
|
+
@options[:except] = [@options[:except]] unless @options[:except].is_a?(Array)
|
11
|
+
@options[:status] ||= [200]
|
12
12
|
refresh
|
13
13
|
end
|
14
14
|
|
@@ -19,12 +19,12 @@ module Heroku
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def can_insert?(env)
|
22
|
-
return unless @status
|
22
|
+
return unless @options[:status].include?(@status)
|
23
23
|
return unless @headers['Content-Type'] =~ /text\/html/ || (@body.respond_to?(:headers) && @body.headers['Content-Type'] =~ /text\/html/)
|
24
24
|
@body_accessor = [:first, :body].detect { |m| @body.respond_to?(m) }
|
25
25
|
return unless @body_accessor
|
26
26
|
return unless @body.send(@body_accessor) =~ /<body.*?>/i
|
27
|
-
return if @except
|
27
|
+
return if @options[:except].any? { |route| env['PATH_INFO'] =~ route }
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
data/spec/nav_spec.rb
CHANGED
@@ -47,6 +47,22 @@ describe Heroku::Nav::Header do
|
|
47
47
|
last_response.body.should.not =~ /<!-- header -->/
|
48
48
|
end
|
49
49
|
|
50
|
+
describe "defining response status" do
|
51
|
+
def app
|
52
|
+
make_app { use Heroku::Nav::Header, :status => [404] }
|
53
|
+
end
|
54
|
+
|
55
|
+
it "respects the :status option" do
|
56
|
+
get '/404', :body => '<html><body>hi'
|
57
|
+
last_response.body.should =~ /<!-- header -->/
|
58
|
+
end
|
59
|
+
|
60
|
+
it "allows overriding the default status" do
|
61
|
+
get '/', :body => '<html><body>hi'
|
62
|
+
last_response.body.should.not =~ /<!-- header -->/
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
50
66
|
describe "excluding paths" do
|
51
67
|
def app
|
52
68
|
make_app { use Heroku::Nav::Header, :except => [/x/, /alt/] }
|
@@ -54,7 +70,7 @@ describe Heroku::Nav::Header do
|
|
54
70
|
|
55
71
|
it "respects the :except option" do
|
56
72
|
get '/alternate', :body => '<html><body>hi'
|
57
|
-
last_response.body.should.
|
73
|
+
last_response.body.should.not =~ /<!-- header -->/
|
58
74
|
end
|
59
75
|
end
|
60
76
|
end
|