deputy 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/deputy.gemspec +2 -2
  3. data/lib/deputy.rb +25 -1
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.19
1
+ 0.1.20
data/deputy.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deputy}
8
- s.version = "0.1.19"
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 = ["Michael Grosser"]
12
- s.date = %q{2010-06-06}
12
+ s.date = %q{2010-06-07}
13
13
  s.default_executable = %q{deputy}
14
14
  s.email = %q{mirko@dawanda.com}
15
15
  s.executables = ["deputy"]
data/lib/deputy.rb CHANGED
@@ -115,7 +115,9 @@ module Deputy
115
115
 
116
116
  def self.get(path)
117
117
  url = "#{sheriff_url}#{path}"
118
- open(url).read
118
+ Timeout.timeout(1) do
119
+ open(url).read
120
+ end
119
121
  rescue => e
120
122
  e.message << url
121
123
  raise e
@@ -132,4 +134,26 @@ module Deputy
132
134
  end
133
135
  raise "No deputy.yml found in /etc or #{home}"
134
136
  end
137
+
138
+ # stolen from klarlack -- http://github.com/schoefmax/klarlack
139
+ # to get an reliable timeout that wont fail on other platforms
140
+ # or if sytem_timer is missing
141
+ Timeout = begin
142
+ # Try to use the SystemTimer gem instead of Ruby's timeout library
143
+ # when running on something that looks like Ruby 1.8.x. See:
144
+ # http://ph7spot.com/articles/system_timer
145
+ # We don't want to bother trying to load SystemTimer on jruby and
146
+ # ruby 1.9+.
147
+ if RUBY_VERSION =~ /^1\.8\./ and RUBY_PLATFORM !~ /java/
148
+ require 'system_timer'
149
+ SystemTimer
150
+ else
151
+ require 'timeout'
152
+ Timeout
153
+ end
154
+ rescue LoadError => e
155
+ $stderr.puts "Could not load SystemTimer gem, falling back to Ruby's slower/unsafe timeout library: #{e.message}"
156
+ require 'timeout'
157
+ Timeout
158
+ end
135
159
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 19
9
- version: 0.1.19
8
+ - 20
9
+ version: 0.1.20
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-06 00:00:00 +02:00
17
+ date: 2010-06-07 00:00:00 +02:00
18
18
  default_executable: deputy
19
19
  dependencies: []
20
20