pry-em 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pry-em.rb +16 -16
- metadata +48 -65
data/lib/pry-em.rb
CHANGED
@@ -33,7 +33,7 @@ EmCommands = Pry::CommandSet.new do
|
|
33
33
|
#
|
34
34
|
# We don't want to keep turning the reactor on and off, as that would limit some
|
35
35
|
# of the things the user might want to do.
|
36
|
-
|
36
|
+
$retval, $em_state = [nil, :waiting]
|
37
37
|
|
38
38
|
# Boot EM before eval'ing the source as it's likely to depend on the reactor.
|
39
39
|
run_em_if_necessary!
|
@@ -84,8 +84,8 @@ EmCommands = Pry::CommandSet.new do
|
|
84
84
|
# confused.
|
85
85
|
def handle_unexpected_error(e)
|
86
86
|
if waiting?
|
87
|
-
|
88
|
-
|
87
|
+
$em_state = :em_error
|
88
|
+
$retval = e
|
89
89
|
else
|
90
90
|
output.puts "Unexpected exception from EventMachine reactor"
|
91
91
|
_pry_.last_exception = e
|
@@ -106,43 +106,43 @@ EmCommands = Pry::CommandSet.new do
|
|
106
106
|
def wait_for_deferrable(deferrable, timeout)
|
107
107
|
|
108
108
|
if timeout
|
109
|
-
EM::Timer.new(timeout) {
|
109
|
+
EM::Timer.new(timeout) { $em_state = :timeout if waiting? }
|
110
110
|
end
|
111
111
|
|
112
112
|
[:callback, :errback].each do |method|
|
113
113
|
begin
|
114
114
|
deferrable.__send__ method do |*result|
|
115
|
-
|
116
|
-
|
115
|
+
$em_state = method
|
116
|
+
$retval = result.size > 1 ? result : result.first
|
117
117
|
end
|
118
118
|
rescue NoMethodError
|
119
|
-
|
120
|
-
|
119
|
+
$retval = deferrable
|
120
|
+
$em_state = :callback
|
121
121
|
break
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
sleep 0.01 until
|
125
|
+
sleep 0.01 until $em_state != :waiting
|
126
126
|
|
127
|
-
raise "Timeout after #{timeout} seconds" if
|
127
|
+
raise "Timeout after #{timeout} seconds" if $em_state == :timeout
|
128
128
|
|
129
129
|
# Use Pry's (admittedly nascent) handling for exceptions where possible.
|
130
|
-
raise
|
130
|
+
raise $retval if $em_state != :callback && Exception === $retval
|
131
131
|
|
132
132
|
# TODO: This doesn't interact well with the pager.
|
133
|
-
output.print "#{
|
133
|
+
output.print "#{$em_state} " if $em_state != :callback
|
134
134
|
|
135
|
-
|
135
|
+
$retval
|
136
136
|
|
137
|
-
# If the main thread is interrupted we must ensure that the
|
137
|
+
# If the main thread is interrupted we must ensure that the $em_state
|
138
138
|
# is no-longer :waiting so that handle_unexpected_error can do the
|
139
139
|
# right thing.
|
140
140
|
ensure
|
141
|
-
|
141
|
+
$em_state = :interrupted if waiting?
|
142
142
|
end
|
143
143
|
|
144
144
|
def waiting?
|
145
|
-
|
145
|
+
$em_state == :waiting
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
metadata
CHANGED
@@ -1,98 +1,81 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-em
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 0.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Conrad Irwin
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: pry
|
16
|
+
type: :runtime
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>'
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.8
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 43
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 9
|
33
|
-
- 8
|
26
|
+
requirements:
|
27
|
+
- - ! '>'
|
28
|
+
- !ruby/object:Gem::Version
|
34
29
|
version: 0.9.8
|
35
|
-
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
30
|
+
- !ruby/object:Gem::Dependency
|
38
31
|
name: eventmachine
|
32
|
+
type: :runtime
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
version: "0"
|
49
|
-
type: :runtime
|
50
|
-
version_requirements: *id002
|
51
|
-
description: em! is a synchronous wrapper around deferrables, so that you can interact with them as though they were normal function calls.
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: em! is a synchronous wrapper around deferrables, so that you can interact
|
47
|
+
with them as though they were normal function calls.
|
52
48
|
email: conrad.irwin@gmail.com
|
53
49
|
executables: []
|
54
|
-
|
55
50
|
extensions: []
|
56
|
-
|
57
51
|
extra_rdoc_files: []
|
58
|
-
|
59
|
-
files:
|
52
|
+
files:
|
60
53
|
- lib/pry-em.rb
|
61
54
|
- README.markdown
|
62
55
|
- LICENSE.MIT
|
63
|
-
has_rdoc: true
|
64
56
|
homepage: http://github.com/ConradIrwin/pry-em
|
65
57
|
licenses: []
|
66
|
-
|
67
58
|
post_install_message:
|
68
59
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
60
|
+
require_paths:
|
71
61
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
63
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
- 0
|
80
|
-
version: "0"
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
69
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
90
74
|
requirements: []
|
91
|
-
|
92
75
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.8.23
|
94
77
|
signing_key:
|
95
78
|
specification_version: 3
|
96
79
|
summary: Provides an em! function that can be used to play with deferrable more easily.
|
97
80
|
test_files: []
|
98
|
-
|
81
|
+
has_rdoc:
|