right_popen 1.0.6-x86-mswin32-60 → 1.0.7-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,12 +9,14 @@ include Config
9
9
 
10
10
  desc "Clean any build files for right_popen"
11
11
  task :clean do
12
- if File.exists?('ext/Makefile')
13
- Dir.chdir('ext') do
14
- sh 'nmake distclean'
12
+ if RUBY_PLATFORM =~ /mswin/
13
+ if File.exists?('ext/Makefile')
14
+ Dir.chdir('ext') do
15
+ sh 'nmake distclean'
16
+ end
15
17
  end
18
+ rm 'lib/win32/right_popen.so' if File.file?('lib/win32/right_popen.so')
16
19
  end
17
- rm 'lib/win32/right_popen.so' if File.file?('lib/win32/right_popen.so')
18
20
  end
19
21
 
20
22
  desc "Build right_popen (but don't install it)"
@@ -30,13 +32,13 @@ task :build => [:clean] do
30
32
  end
31
33
 
32
34
  desc "Build a binary gem"
33
- task :build_binary_gem => [:build] do
35
+ task :gem => [:build] do
34
36
  Dir["*.gem"].each { |gem| rm gem }
35
37
  ruby 'right_popen.gemspec'
36
38
  end
37
39
 
38
40
  desc 'Install the right_popen library as a gem'
39
- task :install_gem => [:build_binary_gem] do
41
+ task :install_gem => [:gem] do
40
42
  file = Dir["*.gem"].first
41
43
  sh "gem install #{file}"
42
44
  end
@@ -23,9 +23,9 @@
23
23
 
24
24
  require 'rubygems'
25
25
  begin
26
- gem 'eventmachine', '=0.12.8.1' # patched version for Windows-only socket close fix
26
+ gem 'eventmachine', '=0.12.10.1' # patched version for Windows-only socket close fix
27
27
  rescue Gem::LoadError
28
- gem 'eventmachine', '=0.12.8' # notify_readable is deprecated, so currently cannot use >=0.12.10 in Windows gem
28
+ gem 'eventmachine', '=0.12.10'
29
29
  end
30
30
  require 'eventmachine'
31
31
  require 'win32/process'
@@ -122,7 +122,7 @@ module RightScale
122
122
 
123
123
  # Callback from EM to unbind.
124
124
  def unbind
125
- # We force the attached stderr handler to go away so that
125
+ # We force the stderr watched handler to go away so that
126
126
  # we don't end up with a broken pipe
127
127
  @stderr_eventable.force_detach if @stderr_eventable
128
128
  @target.method(@exit_handler).call(get_status) if @exit_handler
@@ -198,13 +198,13 @@ module RightScale
198
198
  # attach handlers to event machine and let it monitor incoming data. the
199
199
  # streams aren't used directly by the connectors except that they are closed
200
200
  # on unbind.
201
- stderr_eventable = EM.attach(stream_err, StdErrHandler, options[:target], options[:stderr_handler], stream_err) if options[:stderr_handler]
202
- EM.attach(stream_out, StdOutHandler, options[:target], options[:stdout_handler], options[:exit_handler], stderr_eventable, stream_out, pid)
201
+ stderr_eventable = EM.watch(stream_err, StdErrHandler, options[:target], options[:stderr_handler], stream_err) { |c| c.notify_readable = true } if options[:stderr_handler]
202
+ EM.watch(stream_out, StdOutHandler, options[:target], options[:stdout_handler], options[:exit_handler], stderr_eventable, stream_out, pid) { |c| c.notify_readable = true }
203
203
 
204
204
  # note that control returns to the caller, but the launched cmd continues
205
205
  # running and sends output to the handlers. the caller is not responsible
206
206
  # for waiting for the process to terminate or closing streams as the
207
- # attached eventables will handle this automagically. notification will be
207
+ # watched eventables will handle this automagically. notification will be
208
208
  # sent to the exit_handler on process termination.
209
209
  end
210
210
 
Binary file
data/right_popen.gemspec CHANGED
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  spec = Gem::Specification.new do |spec|
8
8
  spec.name = 'right_popen'
9
- spec.version = '1.0.6'
9
+ spec.version = '1.0.7'
10
10
  spec.authors = ['Scott Messier', 'Raphael Simon']
11
11
  spec.email = 'scott@rightscale.com'
12
12
  spec.homepage = 'https://github.com/rightscale/right_popen'
@@ -48,13 +48,12 @@ EOF
48
48
  end
49
49
  spec.files = candidates.sort!
50
50
 
51
- # Current implementation supports >= 0.12.8
52
- spec.add_runtime_dependency(%q<eventmachine>, [">= 0.12.8"])
51
+ # Current implementation supports >= 0.12.10
52
+ spec.add_runtime_dependency(%q<eventmachine>, [">= 0.12.10"])
53
53
  if is_windows?
54
54
  # Windows implementation currently depends on deprecated behavior from
55
55
  # 0.12.8, but we also need to support the 0.12.8.1 patch version. the Linux
56
56
  # side is free to use 0.12.10+
57
- spec.add_runtime_dependency(%q<eventmachine>, ["< 0.12.9"])
58
57
  spec.add_runtime_dependency(%q<win32-process>, [">= 0.6.1"])
59
58
  end
60
59
  end
@@ -33,6 +33,7 @@ describe 'RightScale::popen3' do
33
33
  attr_reader :output_text, :error_text, :status
34
34
 
35
35
  def do_right_popen(command, env=nil)
36
+ @timeout = EM::Timer.new(10) { puts "** Failed: Timeout"; EM.stop }
36
37
  @output_text = ''
37
38
  @error_text = ''
38
39
  @status = nil
@@ -45,45 +46,16 @@ describe 'RightScale::popen3' do
45
46
  end
46
47
 
47
48
  def run_right_popen(command, env=nil, count = 1)
48
- puts "#{count}>" if count > 1
49
- last_iteration = 0
50
- EM.next_tick do
51
- do_right_popen(command, env)
52
- end
53
- EM.run do
54
- timer = EM::PeriodicTimer.new(0.05) do
55
- begin
56
- if @done || @last_exception
57
- last_iteration = last_iteration + 1
58
- if @last_exception.nil? && last_iteration < count
59
- @done = false
60
- EM.next_tick do
61
- if count > 1
62
- print '+'
63
- STDOUT.flush
64
- end
65
- do_right_popen(command, env)
66
- end
67
- else
68
- puts "<" if count > 1
69
- timer.cancel
70
- EM.stop
71
- end
72
- end
73
- rescue Exception => e
74
- @last_exception = e
75
- timer.cancel
76
- EM.stop
77
- end
78
- end
79
- end
80
- if @last_exception
81
- if count > 1
82
- message = "<#{last_iteration + 1}\n#{last_exception.message}"
83
- else
84
- message = last_exception.message
85
- end
86
- raise @last_exception.class, "#{message}\n#{@last_exception.backtrace.join("\n")}"
49
+ begin
50
+ @command = command
51
+ @env = env
52
+ @last_iteration = 0
53
+ @count = count
54
+ puts "#{count}>" if count > 1
55
+ EM.run { EM.next_tick { do_right_popen(command, env) } }
56
+ rescue Exception => e
57
+ puts "** Failed: #{e.message} FROM\n#{e.backtrace.join("\n")}"
58
+ raise e
87
59
  end
88
60
  end
89
61
 
@@ -96,8 +68,19 @@ describe 'RightScale::popen3' do
96
68
  end
97
69
 
98
70
  def on_exit(status)
71
+ @last_iteration += 1
72
+ @timeout.cancel if @timeout
73
+ if @last_iteration < @count
74
+ EM.next_tick do
75
+ print '+'
76
+ STDOUT.flush
77
+ do_right_popen(@command, @env)
78
+ end
79
+ else
80
+ puts "<" if @count > 1
81
+ EM.stop
82
+ end
99
83
  @status = status
100
- @done = true
101
84
  end
102
85
  end
103
86
 
@@ -205,6 +188,14 @@ describe 'RightScale::popen3' do
205
188
  runner.status.exitstatus.should == 0
206
189
  runner.output_text.should include('PATH=c:\\bogus\\bin;')
207
190
  end
191
+ else
192
+ it 'should allow running bash command lines starting with a built-in command' do
193
+ command = "for i in 1 2 3 4 5; do echo $i;done"
194
+ runner = RightPopenSpec::Runner.new
195
+ runner.run_right_popen(command)
196
+ runner.status.exitstatus.should == 0
197
+ runner.output_text.should == "1\n2\n3\n4\n5\n"
198
+ end
208
199
  end
209
200
 
210
201
  it 'should run repeatedly without leaking resources' do
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_popen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 7
9
+ version: 1.0.7
5
10
  platform: x86-mswin32-60
6
11
  authors:
7
12
  - Scott Messier
@@ -10,40 +15,43 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2010-03-16 00:00:00 -07:00
18
+ date: 2010-04-27 00:00:00 -07:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: eventmachine
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
24
- version: 0.12.8
25
- version:
26
- - !ruby/object:Gem::Dependency
27
- name: eventmachine
28
+ segments:
29
+ - 0
30
+ - 12
31
+ - 10
32
+ version: 0.12.10
28
33
  type: :runtime
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - <
33
- - !ruby/object:Gem::Version
34
- version: 0.12.9
35
- version:
34
+ version_requirements: *id001
36
35
  - !ruby/object:Gem::Dependency
37
36
  name: win32-process
38
- type: :runtime
39
- version_requirement:
40
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
41
39
  requirements:
42
40
  - - ">="
43
41
  - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 6
45
+ - 1
44
46
  version: 0.6.1
45
- version:
46
- description: RightPopen allows running external processes aynchronously while still capturing their standard and error outputs. It relies on EventMachine for most of its internal mechanisms. The Linux implementation is valid for any Linux platform but there is also a native implementation for Windows platforms.
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: |
50
+ RightPopen allows running external processes aynchronously while still
51
+ capturing their standard and error outputs. It relies on EventMachine for most
52
+ of its internal mechanisms. The Linux implementation is valid for any Linux
53
+ platform but there is also a native implementation for Windows platforms.
54
+
47
55
  email: scott@rightscale.com
48
56
  executables: []
49
57
 
@@ -56,12 +64,9 @@ files:
56
64
  - README.rdoc
57
65
  - Rakefile
58
66
  - ext/extconf.rb
59
- - ext/win32
60
67
  - ext/win32/right_popen.c
61
68
  - ext/win32/right_popen.h
62
- - lib/linux
63
69
  - lib/right_popen.rb
64
- - lib/win32
65
70
  - lib/win32/right_popen.rb
66
71
  - lib/win32/right_popen.so
67
72
  - right_popen.gemspec
@@ -75,6 +80,8 @@ files:
75
80
  - spec/spec_helper.rb
76
81
  has_rdoc: true
77
82
  homepage: https://github.com/rightscale/right_popen
83
+ licenses: []
84
+
78
85
  post_install_message:
79
86
  rdoc_options:
80
87
  - --main
@@ -87,20 +94,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
94
  requirements:
88
95
  - - ">="
89
96
  - !ruby/object:Gem::Version
97
+ segments:
98
+ - 1
99
+ - 8
100
+ - 6
90
101
  version: 1.8.6
91
- version:
92
102
  required_rubygems_version: !ruby/object:Gem::Requirement
93
103
  requirements:
94
104
  - - ">="
95
105
  - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
96
108
  version: "0"
97
- version:
98
109
  requirements: []
99
110
 
100
111
  rubyforge_project: right_popen
101
- rubygems_version: 1.3.1
112
+ rubygems_version: 1.3.6
102
113
  signing_key:
103
- specification_version: 2
114
+ specification_version: 3
104
115
  summary: Provides a platform-independent popen implementation
105
116
  test_files: []
106
117