schmurfy-bacon 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bacon/ext/em.rb CHANGED
@@ -11,11 +11,25 @@ require 'eventmachine'
11
11
  #
12
12
  module Bacon
13
13
  module EMSpec # :nodoc:
14
-
14
+ class << self
15
+ attr_accessor :context_fiber
16
+ end
17
+
18
+ def wakeup
19
+ # this should be enough but for some reason the reactor
20
+ # idles for 20 seconds on EM::stop before really exiting
21
+ # @waiting_fiber.resume
22
+
23
+ if @waiting_fiber
24
+ EM::next_tick { @waiting_fiber.resume }
25
+ end
26
+ end
27
+
15
28
  def wait(timeout = 0.1, &block)
16
29
  @waiting_fiber = Fiber.current
17
30
  EM::cancel_timer(@timeout)
18
- @timeout = EM::add_timer(timeout){ @waiting_fiber.resume }
31
+ EM::add_timer(timeout, &method(:wakeup))
32
+
19
33
  Fiber.yield
20
34
 
21
35
  @waiting_fiber = nil
@@ -25,19 +39,25 @@ module Bacon
25
39
 
26
40
  def done
27
41
  EM.cancel_timer(@timeout)
28
- @waiting_fiber.resume if @waiting_fiber
42
+ wakeup
29
43
  end
30
44
 
31
45
  def run(*)
32
- subcontext = EM::reactor_running?
33
- if subcontext
46
+ if EMSpec.context_fiber == Fiber.current
34
47
  super
35
48
  else
36
49
  EM::run do
37
- Fiber.new do
38
- super
39
- EM::stop_event_loop
40
- end.resume
50
+
51
+ EMSpec.context_fiber = Fiber.new do
52
+ begin
53
+ super
54
+ EM::stop_event_loop
55
+ ensure
56
+ EMSpec.context_fiber = nil
57
+ end
58
+ end
59
+
60
+ EMSpec.context_fiber.resume
41
61
  end
42
62
 
43
63
  end
data/lib/bacon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bacon
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
 
2
3
  require 'term/ansicolor'
3
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schmurfy-bacon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
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-04-11 00:00:00.000000000 Z
12
+ date: 2012-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &70328114246540 !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'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70328114246540
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: ! 'Bacon is a small RSpec clone weighing less than 350 LoC but
26
31
 
27
32
  nevertheless providing all essential features.
@@ -77,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
82
  version: '0'
78
83
  segments:
79
84
  - 0
80
- hash: -3752377546693975737
85
+ hash: 2049935721437851805
81
86
  required_rubygems_version: !ruby/object:Gem::Requirement
82
87
  none: false
83
88
  requirements:
@@ -86,10 +91,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
91
  version: '0'
87
92
  segments:
88
93
  - 0
89
- hash: -3752377546693975737
94
+ hash: 2049935721437851805
90
95
  requirements: []
91
96
  rubyforge_project:
92
- rubygems_version: 1.8.11
97
+ rubygems_version: 1.8.22
93
98
  signing_key:
94
99
  specification_version: 3
95
100
  summary: a small RSpec clone