heroku-nav 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/heroku-nav.gemspec +14 -17
- data/lib/heroku/nav.rb +6 -20
- data/spec/nav_spec.rb +0 -11
- metadata +22 -8
- data/.gitignore +0 -1
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ begin
|
|
21
21
|
gemspec.add_dependency(%q<rest-client>, [">= 1.0"])
|
22
22
|
gemspec.add_dependency(%q<json>, [">= 0"])
|
23
23
|
|
24
|
-
gemspec.version = '0.1.
|
24
|
+
gemspec.version = '0.1.20'
|
25
25
|
end
|
26
26
|
rescue LoadError
|
27
27
|
puts "Jeweler not available. Install it with: gem install jeweler"
|
data/heroku-nav.gemspec
CHANGED
@@ -1,46 +1,43 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{heroku-nav}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.20"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Dollar", "Pedro Belo", "Todd Matthews"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-10}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = ["david@heroku.com", "pedro@heroku.com", "todd@heroku.com"]
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.md"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
"spec/nav_spec.rb"
|
19
|
+
"README.md",
|
20
|
+
"Rakefile",
|
21
|
+
"heroku-nav.gemspec",
|
22
|
+
"lib/heroku/nav.rb",
|
23
|
+
"spec/api_spec.rb",
|
24
|
+
"spec/base.rb",
|
25
|
+
"spec/nav_spec.rb"
|
27
26
|
]
|
28
27
|
s.homepage = %q{http://heroku.com}
|
29
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
30
28
|
s.require_paths = ["lib"]
|
31
|
-
s.rubygems_version = %q{1.
|
29
|
+
s.rubygems_version = %q{1.4.2}
|
32
30
|
s.summary = %q{}
|
33
31
|
s.test_files = [
|
34
32
|
"spec/api_spec.rb",
|
35
|
-
|
36
|
-
|
33
|
+
"spec/base.rb",
|
34
|
+
"spec/nav_spec.rb"
|
37
35
|
]
|
38
36
|
|
39
37
|
if s.respond_to? :specification_version then
|
40
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
38
|
s.specification_version = 3
|
42
39
|
|
43
|
-
if Gem::Version.new(Gem::
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
41
|
s.add_development_dependency(%q<baconmocha>, [">= 0"])
|
45
42
|
s.add_development_dependency(%q<sinatra>, [">= 0"])
|
46
43
|
s.add_development_dependency(%q<rack-test>, [">= 0"])
|
data/lib/heroku/nav.rb
CHANGED
@@ -8,8 +8,7 @@ module Heroku
|
|
8
8
|
def initialize(app, options={})
|
9
9
|
@app = app
|
10
10
|
@options = options
|
11
|
-
@options[:
|
12
|
-
@options[:except] = [@options[:except]].compact unless @options[:except].is_a?(Array)
|
11
|
+
@options[:except] = [@options[:except]] unless @options[:except].is_a?(Array)
|
13
12
|
@options[:status] ||= [200]
|
14
13
|
refresh
|
15
14
|
end
|
@@ -17,31 +16,18 @@ module Heroku
|
|
17
16
|
def call(env)
|
18
17
|
@status, @headers, @body = @app.call(env)
|
19
18
|
@body.extend(Enumerable)
|
20
|
-
@body = @body.
|
19
|
+
@body = @body.to_a.join
|
21
20
|
insert! if can_insert?(env)
|
22
21
|
[@status, @headers, [@body]]
|
23
22
|
end
|
24
23
|
|
25
24
|
def can_insert?(env)
|
26
25
|
return unless @options[:status].include?(@status)
|
27
|
-
return unless @headers['Content-Type'] =~ /text\/html/
|
28
|
-
return if
|
29
|
-
return if @options[:except].any? { |route| match_route(route, env['PATH_INFO']) }
|
26
|
+
return unless @headers['Content-Type'] =~ /text\/html/ || @headers['content-type'] =~ /text\/html/
|
27
|
+
return if @options[:except].any? { |route| env['PATH_INFO'] =~ route }
|
30
28
|
true
|
31
29
|
end
|
32
30
|
|
33
|
-
def match_route(route, path)
|
34
|
-
return unless route
|
35
|
-
case route.class.name
|
36
|
-
when 'Regexp'
|
37
|
-
path =~ route
|
38
|
-
when 'String'
|
39
|
-
path.chomp('/') == route.chomp('/')
|
40
|
-
else
|
41
|
-
raise "Don't know how to match the route: #{route} (#{route.class.name})"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
31
|
def refresh
|
46
32
|
@nav = self.class.fetch
|
47
33
|
end
|
@@ -79,7 +65,7 @@ module Heroku
|
|
79
65
|
class Header < Base
|
80
66
|
def insert!
|
81
67
|
if @nav['html']
|
82
|
-
@body.gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/header.css' media='all' rel='stylesheet' type='text/css' />")
|
68
|
+
@body.gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/header.css' media='all' rel='stylesheet' type='text/css' />")
|
83
69
|
@body.gsub!(/(<body.*?>\s*(<div .*?class=["'].*?container.*?["'].*?>)?)/i, "\\1#{@nav['html']}")
|
84
70
|
@headers['Content-Length'] = @body.length.to_s
|
85
71
|
end
|
@@ -89,7 +75,7 @@ module Heroku
|
|
89
75
|
class Footer < Base
|
90
76
|
def insert!
|
91
77
|
if @nav['html']
|
92
|
-
@body.gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/footer.css' media='all' rel='stylesheet' type='text/css' />")
|
78
|
+
@body.gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/footer.css' media='all' rel='stylesheet' type='text/css' />")
|
93
79
|
@body.gsub!(/(<\/body>)/i, "#{@nav['html']}\\1")
|
94
80
|
@headers['Content-Length'] = @body.length.to_s
|
95
81
|
end
|
data/spec/nav_spec.rb
CHANGED
@@ -65,17 +65,6 @@ describe Heroku::Nav::Header do
|
|
65
65
|
last_response.body.should.not =~ /<!-- header -->/
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
69
|
-
describe "only including certain paths" do
|
70
|
-
def app
|
71
|
-
make_app { use Heroku::Nav::Header, :only => /x/ }
|
72
|
-
end
|
73
|
-
|
74
|
-
it "respects the :only option" do
|
75
|
-
get '/alternate', :body => '<html><body>hi'
|
76
|
-
last_response.body.should.not =~ /<!-- header -->/
|
77
|
-
end
|
78
|
-
end
|
79
68
|
end
|
80
69
|
|
81
70
|
describe Heroku::Nav::Footer do
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-nav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 51
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 20
|
10
|
+
version: 0.1.20
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- David Dollar
|
@@ -16,16 +17,18 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date:
|
20
|
+
date: 2011-01-10 00:00:00 -05:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: baconmocha
|
24
25
|
prerelease: false
|
25
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
26
28
|
requirements:
|
27
29
|
- - ">="
|
28
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
29
32
|
segments:
|
30
33
|
- 0
|
31
34
|
version: "0"
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: sinatra
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
version: "0"
|
@@ -47,9 +52,11 @@ dependencies:
|
|
47
52
|
name: rack-test
|
48
53
|
prerelease: false
|
49
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - ">="
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
53
60
|
segments:
|
54
61
|
- 0
|
55
62
|
version: "0"
|
@@ -59,9 +66,11 @@ dependencies:
|
|
59
66
|
name: rest-client
|
60
67
|
prerelease: false
|
61
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
62
70
|
requirements:
|
63
71
|
- - ">="
|
64
72
|
- !ruby/object:Gem::Version
|
73
|
+
hash: 15
|
65
74
|
segments:
|
66
75
|
- 1
|
67
76
|
- 0
|
@@ -72,9 +81,11 @@ dependencies:
|
|
72
81
|
name: json
|
73
82
|
prerelease: false
|
74
83
|
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
75
85
|
requirements:
|
76
86
|
- - ">="
|
77
87
|
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
78
89
|
segments:
|
79
90
|
- 0
|
80
91
|
version: "0"
|
@@ -92,7 +103,6 @@ extensions: []
|
|
92
103
|
extra_rdoc_files:
|
93
104
|
- README.md
|
94
105
|
files:
|
95
|
-
- .gitignore
|
96
106
|
- README.md
|
97
107
|
- Rakefile
|
98
108
|
- heroku-nav.gemspec
|
@@ -105,28 +115,32 @@ homepage: http://heroku.com
|
|
105
115
|
licenses: []
|
106
116
|
|
107
117
|
post_install_message:
|
108
|
-
rdoc_options:
|
109
|
-
|
118
|
+
rdoc_options: []
|
119
|
+
|
110
120
|
require_paths:
|
111
121
|
- lib
|
112
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
113
124
|
requirements:
|
114
125
|
- - ">="
|
115
126
|
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
116
128
|
segments:
|
117
129
|
- 0
|
118
130
|
version: "0"
|
119
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
120
133
|
requirements:
|
121
134
|
- - ">="
|
122
135
|
- !ruby/object:Gem::Version
|
136
|
+
hash: 3
|
123
137
|
segments:
|
124
138
|
- 0
|
125
139
|
version: "0"
|
126
140
|
requirements: []
|
127
141
|
|
128
142
|
rubyforge_project:
|
129
|
-
rubygems_version: 1.
|
143
|
+
rubygems_version: 1.4.2
|
130
144
|
signing_key:
|
131
145
|
specification_version: 3
|
132
146
|
summary: ""
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
pkg/
|