em-systemcommand 2.0.6 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -109,12 +109,18 @@ module EventMachine
109
109
  pipes.delete name
110
110
  if pipes.empty?
111
111
  exit_callbacks.each do |cb|
112
- cb.call status
112
+ EM.next_tick do
113
+ cb.call status
114
+ end
113
115
  end
114
116
  if status.exitstatus == 0
115
- succeed self
117
+ EM.next_tick do
118
+ succeed self
119
+ end
116
120
  else
117
- fail self
121
+ EM.next_tick do
122
+ fail self
123
+ end
118
124
  end
119
125
  end
120
126
  end
@@ -36,9 +36,13 @@ module EventMachine
36
36
  if matches.length > 0
37
37
  case opt[:match]
38
38
  when :first
39
- block.call *matches[0]
39
+ EM.next_tick do
40
+ block.call *matches[0]
41
+ end
40
42
  when :last
41
- block.call *matches[matches.length-1]
43
+ EM.next_tick do
44
+ block.call *matches[matches.length-1]
45
+ end
42
46
  end
43
47
  end
44
48
  end
@@ -50,7 +54,9 @@ module EventMachine
50
54
  # @param [String] line The line that´s received
51
55
  def receive_line line
52
56
  receive_line_callbacks.each do |callback|
53
- callback.call line.dup
57
+ EM.next_tick do
58
+ callback.call line.dup
59
+ end
54
60
  end
55
61
  end
56
62
 
@@ -70,7 +76,9 @@ module EventMachine
70
76
  # @param [String] buffer The complete buffer content of this connection
71
77
  def receive_update buffer
72
78
  receive_update_callbacks.each do |callback|
73
- callback.call buffer.dup
79
+ EM.next_tick do
80
+ callback.call buffer.dup
81
+ end
74
82
  end
75
83
  end
76
84
 
@@ -91,7 +99,9 @@ module EventMachine
91
99
  # if recursive is true we already invoked the receive data callbacks!
92
100
  unless recursive
93
101
  receive_data_callbacks.each do |callback|
94
- callback.call data.dup
102
+ EM.next_tick do
103
+ callback.call data.dup
104
+ end
95
105
  end
96
106
  end
97
107
  @linebuffer ||= []
@@ -111,6 +121,8 @@ module EventMachine
111
121
  ln = (@linebuffer << data[0...ix]).join
112
122
  @linebuffer.clear
113
123
 
124
+ ln.force_encoding("UTF-8")
125
+
114
126
  receive_line ln
115
127
  @outputbuffer.print ln
116
128
 
@@ -131,6 +143,8 @@ module EventMachine
131
143
  @linebuffer.clear
132
144
  ln.chomp!
133
145
 
146
+ ln.force_encoding("UTF-8")
147
+
134
148
  receive_line ln
135
149
  @outputbuffer.print ln
136
150
 
@@ -185,9 +199,10 @@ module EventMachine
185
199
  def close
186
200
  begin
187
201
  @io.close unless @io.closed?
188
- detach
189
202
  rescue Exception => e
190
203
  # ignore errors, when the io object might be closed already
204
+ ensure
205
+ detach
191
206
  end
192
207
  end
193
208
 
@@ -1,5 +1,5 @@
1
1
  module Em
2
2
  module Systemcommand
3
- VERSION = "2.0.6"
3
+ VERSION = "2.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-systemcommand
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-06 00:00:00.000000000 Z
12
+ date: 2012-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -163,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  segments:
165
165
  - 0
166
- hash: 4350804732242013676
166
+ hash: -1991504117051574019
167
167
  required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  none: false
169
169
  requirements:
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: 4350804732242013676
175
+ hash: -1991504117051574019
176
176
  requirements: []
177
177
  rubyforge_project:
178
178
  rubygems_version: 1.8.24