heroku-nav 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- heroku-nav (0.1.24)
4
+ heroku-nav (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  Heroku Nav
2
2
  ==========
3
3
 
4
+ [![Build Status](https://travis-ci.org/heroku/heroku-nav.png?branch=master)](https://travis-ci.org/heroku/heroku-nav)
5
+
4
6
  This is a Ruby gem providing a Rack middleware to help Heroku add-on providers
5
7
  displaying a customized header for users coming from a single sign-on session.
6
8
 
7
-
8
9
  ## Usage ######################################################################
9
10
 
10
11
  Use it just like any Rack middleware:
@@ -31,9 +32,14 @@ To don't display the header on a given request path you can use the `:except` co
31
32
 
32
33
  config.middleware.use Heroku::Nav::Provider, :except => /admin/
33
34
 
34
-
35
35
  ## Meta #######################################################################
36
36
 
37
- Maintained by Pedro Belo, contributions by Todd Matthews and David Dollar.
37
+ Written by Pedro Belo, with contributions from:
38
+
39
+ * Todd Matthews
40
+ * David Dollar
41
+ * Caio Chassot
42
+ * Raul Murciano
43
+ * Jonathan Dance
38
44
 
39
- Released under the MIT license. http://github.com/heroku/heroku-nav
45
+ Released under the MIT license. http://github.com/heroku/heroku-nav
@@ -39,13 +39,14 @@ module Heroku
39
39
  http.use_ssl = true if uri.scheme == 'https'
40
40
  request = Net::HTTP::Get.new(uri.request_uri)
41
41
  request['Accept'] = format
42
- response = Timeout.timeout(10) do
43
- retry_upto(10, :interval => 0.5) do
42
+ timeout = (ENV['HEROKU_NAV_TIMEOUT'] || 10).to_i
43
+ response = Timeout.timeout(timeout) do
44
+ retry_upto(timeout, :interval => 0.5) do
44
45
  http.request(request)
45
46
  end
46
47
  end
47
48
  format == 'application/json' ? OkJson.decode(response.body) : response.body
48
- rescue Exception => e
49
+ rescue Timeout::Error, StandardError => e
49
50
  $stderr.puts "Failed to fetch the Heroku #{resource}: #{e.class.name} - #{e.message}"
50
51
  {}
51
52
  end
@@ -69,7 +70,7 @@ module Heroku
69
70
 
70
71
  def retry_upto(max_retries = 1, opts = {})
71
72
  yield
72
- rescue *(opts[:rescue] || Exception)
73
+ rescue Timeout::Error, StandardError
73
74
  attempt = attempt ? attempt+1 : 1
74
75
  raise if (attempt == max_retries)
75
76
  if interval = opts[:interval]
@@ -19,7 +19,7 @@ describe "Api" do
19
19
  Heroku::Nav::Header.resource_url.should == url
20
20
  end
21
21
 
22
- it "doesn't raise" do
22
+ it "doesn't raise a timeout error" do
23
23
  stub_request(:get, url).to_timeout
24
24
  stderr = wrap_stderr do
25
25
  Heroku::Nav::Header.fetch.should == {}
@@ -27,6 +27,13 @@ describe "Api" do
27
27
  stderr.should == "Failed to fetch the Heroku header: Timeout::Error - execution expired\n"
28
28
  end
29
29
 
30
+ it "raise signals/interrupts" do
31
+ stub_request(:get, url).to_raise(::Interrupt)
32
+ wrap_stderr do
33
+ lambda { Heroku::Nav::Header.fetch }.should.raise(::Interrupt)
34
+ end
35
+ end
36
+
30
37
  it "parses the JSON response, returning the html and css" do
31
38
  Heroku::Nav::Header.fetch.should == { 'html' => '<!-- header -->' }
32
39
  end
@@ -1,5 +1,7 @@
1
1
  $: << File.dirname(__FILE__) + '/../lib'
2
2
 
3
+ ENV['HEROKU_NAV_TIMEOUT'] = '1'
4
+
3
5
  require 'heroku/nav'
4
6
  require 'sinatra/base'
5
7
  require 'bacon'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -125,9 +125,9 @@ extra_rdoc_files:
125
125
  files:
126
126
  - lib/heroku/nav.rb
127
127
  - lib/okjson.rb
128
+ - spec/nav_spec.rb
128
129
  - spec/api_spec.rb
129
130
  - spec/base.rb
130
- - spec/nav_spec.rb
131
131
  - README.md
132
132
  - Gemfile
133
133
  - Gemfile.lock
@@ -157,9 +157,9 @@ signing_key:
157
157
  specification_version: 3
158
158
  summary: ''
159
159
  test_files:
160
+ - spec/nav_spec.rb
160
161
  - spec/api_spec.rb
161
162
  - spec/base.rb
162
- - spec/nav_spec.rb
163
163
  - Gemfile
164
164
  - Gemfile.lock
165
165
  - Rakefile