heroku-nav 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
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.13'
24
+ gemspec.version = '0.1.14'
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,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
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.13"
8
+ s.version = "0.1.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Todd Matthews", "Pedro Belo"]
12
- s.date = %q{2010-05-21}
12
+ s.date = %q{2010-07-21}
13
13
  s.description = %q{}
14
14
  s.email = ["todd@heroku.com", "pedro@heroku.com"]
15
15
  s.files = [
data/lib/heroku/nav.rb CHANGED
@@ -97,5 +97,39 @@ module Heroku
97
97
  @headers['Content-Length'] = @body.send(@body_accessor).size.to_s
98
98
  end
99
99
  end
100
+
101
+ class Provider < Base
102
+ class << self
103
+ def fetch
104
+ Timeout.timeout(4) do
105
+ x=RestClient.get(resource_url).to_s
106
+ puts "fetched: #{x.inspect}"
107
+ x
108
+ end
109
+ rescue => e
110
+ STDERR.puts "Failed to fetch the Heroku #{resource}: #{e.class.name} - #{e.message}"
111
+ {}
112
+ end
113
+
114
+ def resource_url
115
+ "#{api_url}/v1/providers/header"
116
+ end
117
+
118
+ # for non-rack use
119
+ def html
120
+ @@body ||= fetch
121
+ end
122
+ end
123
+
124
+ def insert!
125
+ if @nav
126
+ puts @body.inspect
127
+ @body.send(@body_accessor).gsub!(/(<body.*?>)/i, "\\1#{@nav}")
128
+ @headers['Content-Length'] = @body.send(@body_accessor).size.to_s
129
+ puts "-------"
130
+ puts @body.inspect
131
+ end
132
+ end
133
+ end
100
134
  end
101
135
  end
data/spec/nav_spec.rb CHANGED
@@ -105,5 +105,19 @@ describe Heroku::Nav::Internal do
105
105
  get '/', :body => '<html><body>hi</body>'
106
106
  last_response.body.should.equal '<html><body>hi<!-- body --></body>'
107
107
  end
108
+ end
109
+
110
+ describe Heroku::Nav::Provider do
111
+ before do
112
+ Heroku::Nav::Provider.stubs(:fetch).returns('<!-- heroku header -->')
113
+ end
114
+
115
+ def app
116
+ make_app { use Heroku::Nav::Provider }
117
+ end
108
118
 
119
+ it "adds the body" do
120
+ get '/', :body => '<html><body>hi</body>'
121
+ last_response.body.should.equal '<html><body><!-- heroku header -->hi</body>'
122
+ end
109
123
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 13
9
- version: 0.1.13
8
+ - 14
9
+ version: 0.1.14
10
10
  platform: ruby
11
11
  authors:
12
12
  - Todd Matthews
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-21 00:00:00 -07:00
18
+ date: 2010-07-21 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency