heroku-nav 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +3 -3
  2. data/heroku-nav.gemspec +4 -4
  3. data/lib/heroku/nav.rb +16 -17
  4. metadata +7 -5
data/Rakefile CHANGED
@@ -12,8 +12,8 @@ begin
12
12
  gemspec.summary = ""
13
13
  gemspec.description = ""
14
14
  gemspec.homepage = "http://heroku.com"
15
- gemspec.authors = ["Todd Matthews", "Pedro Belo"]
16
- gemspec.email = ["todd@heroku.com", "pedro@heroku.com"]
15
+ gemspec.authors = ["David Dollar", "Pedro Belo", "Todd Matthews"]
16
+ gemspec.email = ["david@heroku.com", "pedro@heroku.com", "todd@heroku.com"]
17
17
 
18
18
  gemspec.add_development_dependency(%q<baconmocha>, [">= 0"])
19
19
  gemspec.add_development_dependency(%q<sinatra>, [">= 0"])
@@ -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.16'
24
+ gemspec.version = '0.1.17'
25
25
  end
26
26
  rescue LoadError
27
27
  puts "Jeweler not available. Install it with: gem install jeweler"
data/heroku-nav.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{heroku-nav}
8
- s.version = "0.1.16"
8
+ s.version = "0.1.17"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Todd Matthews", "Pedro Belo"]
12
- s.date = %q{2010-07-21}
11
+ s.authors = ["David Dollar", "Pedro Belo", "Todd Matthews"]
12
+ s.date = %q{2010-08-02}
13
13
  s.description = %q{}
14
- s.email = ["todd@heroku.com", "pedro@heroku.com"]
14
+ s.email = ["david@heroku.com", "pedro@heroku.com", "todd@heroku.com"]
15
15
  s.files = [
16
16
  ".gitignore",
17
17
  "Rakefile",
data/lib/heroku/nav.rb CHANGED
@@ -15,16 +15,15 @@ module Heroku
15
15
 
16
16
  def call(env)
17
17
  @status, @headers, @body = @app.call(env)
18
+ @body.extend(Enumerable)
19
+ @body = @body.map.join
18
20
  insert! if can_insert?(env)
19
- [@status, @headers, @body]
21
+ [@status, @headers, [@body]]
20
22
  end
21
23
 
22
24
  def can_insert?(env)
23
25
  return unless @options[:status].include?(@status)
24
- return unless @headers['Content-Type'] =~ /text\/html/ || (@body.respond_to?(:headers) && @body.headers['Content-Type'] =~ /text\/html/)
25
- @body_accessor = [:first, :body].detect { |m| @body.respond_to?(m) }
26
- return unless @body_accessor
27
- return unless @body.send(@body_accessor) =~ /<body.*?>/i
26
+ return unless @headers['Content-Type'] =~ /text\/html/
28
27
  return if @options[:except].any? { |route| env['PATH_INFO'] =~ route }
29
28
  true
30
29
  end
@@ -66,9 +65,9 @@ module Heroku
66
65
  class Header < Base
67
66
  def insert!
68
67
  if @nav['html']
69
- @body.send(@body_accessor).gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/header.css' media='all' rel='stylesheet' type='text/css' />")
70
- @body.send(@body_accessor).gsub!(/(<body.*?>\s*(<div .*?class=["'].*?container.*?["'].*?>)?)/i, "\\1#{@nav['html']}")
71
- @headers['Content-Length'] = @body.send(@body_accessor).size.to_s
68
+ @body.gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/header.css' media='all' rel='stylesheet' type='text/css' />")
69
+ @body.gsub!(/(<body.*?>\s*(<div .*?class=["'].*?container.*?["'].*?>)?)/i, "\\1#{@nav['html']}")
70
+ @headers['Content-Length'] = @body.length.to_s
72
71
  end
73
72
  end
74
73
  end
@@ -76,9 +75,9 @@ module Heroku
76
75
  class Footer < Base
77
76
  def insert!
78
77
  if @nav['html']
79
- @body.send(@body_accessor).gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/footer.css' media='all' rel='stylesheet' type='text/css' />")
80
- @body.send(@body_accessor).gsub!(/(<\/body>)/i, "#{@nav['html']}\\1")
81
- @headers['Content-Length'] = @body.send(@body_accessor).size.to_s
78
+ @body.gsub!(/(<head>)/i, "\\1<link href='#{self.class.api_url}/footer.css' media='all' rel='stylesheet' type='text/css' />")
79
+ @body.gsub!(/(<\/body>)/i, "#{@nav['html']}\\1")
80
+ @headers['Content-Length'] = @body.length.to_s
82
81
  end
83
82
  end
84
83
  end
@@ -89,12 +88,12 @@ module Heroku
89
88
  end
90
89
  def insert!
91
90
  if @nav['head']
92
- @body.send(@body_accessor).gsub!(/(<head>)/i, "\\1#{@nav['head']}")
91
+ @body.gsub!(/(<head>)/i, "\\1#{@nav['head']}")
93
92
  end
94
93
  if @nav['body']
95
- @body.send(@body_accessor).gsub!(/(<\/body>)/i, "#{@nav['body']}\\1")
94
+ @body.gsub!(/(<\/body>)/i, "#{@nav['body']}\\1")
96
95
  end
97
- @headers['Content-Length'] = @body.send(@body_accessor).size.to_s
96
+ @headers['Content-Length'] = @body.length.to_s
98
97
  end
99
98
  end
100
99
 
@@ -121,10 +120,10 @@ module Heroku
121
120
 
122
121
  def insert!
123
122
  if @nav
124
- match = @body.send(@body_accessor).match(/(\<body[^\>]*\>)/i)
123
+ match = @body.match(/(\<body[^\>]*\>)/i)
125
124
  if match.size > 0
126
- @body.send(@body_accessor).insert(match.end(0), @nav)
127
- @headers['Content-Length'] = @body.send(@body_accessor).size.to_s
125
+ @body.insert(match.end(0), @nav)
126
+ @headers['Content-Length'] = @body.length.to_s
128
127
  end
129
128
  end
130
129
  end
metadata CHANGED
@@ -5,17 +5,18 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 16
9
- version: 0.1.16
8
+ - 17
9
+ version: 0.1.17
10
10
  platform: ruby
11
11
  authors:
12
- - Todd Matthews
12
+ - David Dollar
13
13
  - Pedro Belo
14
+ - Todd Matthews
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-07-21 00:00:00 -07:00
19
+ date: 2010-08-02 00:00:00 -07:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -81,8 +82,9 @@ dependencies:
81
82
  version_requirements: *id005
82
83
  description: ""
83
84
  email:
84
- - todd@heroku.com
85
+ - david@heroku.com
85
86
  - pedro@heroku.com
87
+ - todd@heroku.com
86
88
  executables: []
87
89
 
88
90
  extensions: []