em-systemcommand 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -25,7 +25,7 @@ To simply run a process you can instatiate an `EM::SystemCommand`
25
25
  object and set up the callbacks in the yielded block.
26
26
 
27
27
  EM.run do
28
- EM::SystemCommand 'my_command' do |on|
28
+ EM::SystemCommand.execute 'my_command' do |on|
29
29
  on.success do |ps|
30
30
  puts "Success!"
31
31
  end
@@ -40,7 +40,7 @@ When you want to retreive output, you can use the methods
40
40
  `#update`, `#line` and `#data` on a pipe object like so:
41
41
 
42
42
  EM.run do
43
- EM::SystemCommand 'my_command' do |on|
43
+ EM::SystemCommand.execute 'my_command' do |on|
44
44
  on.success do |ps|
45
45
  puts "Success!"
46
46
  end
@@ -66,7 +66,7 @@ When you want to retreive output, you can use the methods
66
66
  you match output against a regular expression:
67
67
 
68
68
  EM.run do
69
- EM::SystemCommand 'echo "25%\n"; sleep 1; echo "50%\n"; sleep 1; echo "75%\n"; sleep 1; echo "100%\n"; exit 0;' do |on|
69
+ EM::SystemCommand.execute 'echo "25%\n"; sleep 1; echo "50%\n"; sleep 1; echo "75%\n"; sleep 1; echo "100%\n"; exit 0;' do |on|
70
70
  on.success do |ps|
71
71
  puts "Success!"
72
72
  end
@@ -116,6 +116,7 @@ module EventMachine
116
116
  def close
117
117
  begin
118
118
  @io.close unless @io.closed?
119
+ detach
119
120
  rescue Exception => e
120
121
  # ignore errors, when the io object might be closed already
121
122
  end
@@ -1,5 +1,5 @@
1
1
  module Em
2
2
  module Systemcommand
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -106,4 +106,35 @@ describe EM::SystemCommand do
106
106
  }
107
107
  end
108
108
  end
109
+
110
+ it 'should pass multiple command executions', focus: true do
111
+ counter = 0
112
+ EM.run do
113
+ 2.times do
114
+ EM::SystemCommand.execute 'ls' do |on|
115
+ on.success do
116
+ 2.times do
117
+ EM::SystemCommand.execute 'ls' do |on2|
118
+ on2.success do
119
+ if counter >= 3
120
+ EM.stop_event_loop
121
+ else
122
+ counter += 1
123
+ end
124
+ end
125
+
126
+ on2.failure do
127
+ if counter >= 3
128
+ EM.stop_event_loop
129
+ else
130
+ counter += 1
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
109
140
  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: 1.0.1
4
+ version: 1.0.2
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-05-24 00:00:00.000000000 Z
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: -2860876855106188560
150
+ hash: 1875739728938098131
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  none: false
153
153
  requirements:
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  segments:
158
158
  - 0
159
- hash: -2860876855106188560
159
+ hash: 1875739728938098131
160
160
  requirements: []
161
161
  rubyforge_project:
162
162
  rubygems_version: 1.8.24