itimer 3 → 4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/itimer.rb +6 -3
  2. data/test/itimer.rb +10 -0
  3. metadata +10 -5
@@ -9,9 +9,12 @@ module Itimer
9
9
  raise klass
10
10
  end
11
11
 
12
- set(:real, seconds)
13
- ret = yield
14
- set(:real, 0)
12
+ begin
13
+ set(:real, seconds)
14
+ ret = yield
15
+ ensure
16
+ set(:real, 0)
17
+ end
15
18
 
16
19
  return ret
17
20
  end
@@ -90,4 +90,14 @@ class ItimerTest < Test::Unit::TestCase
90
90
  end
91
91
  assert_in_delta( Time.now-start, 0.25, 0.1 )
92
92
  end
93
+
94
+ def test_exception
95
+ start = Time.now
96
+ assert_raises( ArgumentError ) do
97
+ Itimer.timeout(1) { raise ArgumentError }
98
+ end
99
+ assert_in_delta( Time.now-start, 0, 0.1 )
100
+
101
+ assert_equal( 0, Itimer.get(:real) )
102
+ end
93
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itimer
3
3
  version: !ruby/object:Gem::Version
4
- version: '3'
4
+ version: '4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-10 00:00:00.000000000Z
12
+ date: 2012-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
16
- requirement: &70188994886360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 0.8.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70188994886360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.0
25
30
  description: Drop-in replacement for stdlib Timeout that uses POSIX interval timers
26
31
  instead of threads. Not as portable but much lighter weight. Also includes low-level
27
32
  wrappers for setitimer and getitimer.
@@ -58,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
63
  version: '0'
59
64
  requirements: []
60
65
  rubyforge_project:
61
- rubygems_version: 1.8.17
66
+ rubygems_version: 1.8.24
62
67
  signing_key:
63
68
  specification_version: 3
64
69
  summary: Timeout replacement using POSIX interval timers