tmm1-em-spec 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em/spec.rb +16 -9
- data/lib/ext/fiber18.rb +7 -0
- metadata +10 -1
data/lib/em/spec.rb
CHANGED
@@ -3,15 +3,17 @@ require File.dirname(__FILE__) + '/../ext/fiber18'
|
|
3
3
|
require 'bacon'
|
4
4
|
|
5
5
|
class Bacon::Context
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
_it(*args){ if block_given? then yield; Fiber.yield end }
|
10
|
-
end
|
11
|
-
def done() $bacon_fiber.resume if $bacon_fiber end
|
12
|
-
alias :resume :done
|
6
|
+
alias :_it :it
|
7
|
+
def it *args
|
8
|
+
_it(*args){ if block_given? then yield; Fiber.yield end }
|
13
9
|
end
|
14
|
-
|
10
|
+
|
11
|
+
def done
|
12
|
+
EM.next_tick{
|
13
|
+
$bacon_fiber.resume if $bacon_fiber
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end unless Bacon::Context.method_defined? :_it
|
15
17
|
|
16
18
|
require 'eventmachine'
|
17
19
|
|
@@ -23,7 +25,7 @@ module EventMachine
|
|
23
25
|
EM.run{
|
24
26
|
Bacon.summary_on_exit
|
25
27
|
($bacon_fiber = Fiber.new{
|
26
|
-
Bacon::Context.new(args.join(' '), &blk)
|
28
|
+
Bacon::Context.new(args.join(' '), &blk).run
|
27
29
|
EM.stop_event_loop
|
28
30
|
}).resume
|
29
31
|
}
|
@@ -33,6 +35,11 @@ end
|
|
33
35
|
|
34
36
|
EM.describe EventMachine do
|
35
37
|
|
38
|
+
should 'work' do
|
39
|
+
1.should == 1
|
40
|
+
done
|
41
|
+
end
|
42
|
+
|
36
43
|
should 'have timers' do
|
37
44
|
start = Time.now
|
38
45
|
|
data/lib/ext/fiber18.rb
CHANGED
@@ -21,11 +21,16 @@ unless defined? Fiber
|
|
21
21
|
|
22
22
|
def resume *args
|
23
23
|
raise FiberError, 'dead fiber called' unless @thread.alive?
|
24
|
+
raise FiberError, 'double resume' if @thread == Thread.current
|
24
25
|
@resume.push(args)
|
25
26
|
result = @yield.pop
|
26
27
|
result.size > 1 ? result : result.first
|
27
28
|
end
|
28
29
|
|
30
|
+
def resume!
|
31
|
+
@resume.push []
|
32
|
+
end
|
33
|
+
|
29
34
|
def yield *args
|
30
35
|
@yield.push(args)
|
31
36
|
result = @resume.pop
|
@@ -45,6 +50,8 @@ unless defined? Fiber
|
|
45
50
|
"#<#{self.class}:0x#{self.object_id.to_s(16)}>"
|
46
51
|
end
|
47
52
|
end
|
53
|
+
else
|
54
|
+
require 'fiber'
|
48
55
|
end
|
49
56
|
|
50
57
|
if __FILE__ == $0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tmm1-em-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Gupta
|
@@ -21,6 +21,15 @@ dependencies:
|
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.12.0
|
23
23
|
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: bacon
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.1.0
|
32
|
+
version:
|
24
33
|
description: Bacon based BDD API for Ruby/EventMachine
|
25
34
|
email: em-spec@tmm1.net
|
26
35
|
executables: []
|