right_popen 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +8 -6
- data/right_popen.gemspec +3 -4
- data/spec/right_popen_spec.rb +23 -40
- metadata +3 -3
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
|
13
|
-
|
14
|
-
|
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 :
|
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 => [:
|
41
|
+
task :install_gem => [:gem] do
|
40
42
|
file = Dir["*.gem"].first
|
41
43
|
sh "gem install #{file}"
|
42
44
|
end
|
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.
|
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.
|
52
|
-
spec.add_runtime_dependency(%q<eventmachine>, [">= 0.12.
|
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
|
data/spec/right_popen_spec.rb
CHANGED
@@ -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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_popen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Messier
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-04-27 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.12.
|
24
|
+
version: 0.12.10
|
25
25
|
version:
|
26
26
|
description: |
|
27
27
|
RightPopen allows running external processes aynchronously while still
|