subprocess 0.16 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  require 'thread'
2
2
  require 'set'
3
3
 
4
+ require 'subprocess/version'
5
+
4
6
  # A Ruby clone of Python's subprocess module.
5
7
  #
6
8
  # @see http://docs.python.org/2/library/subprocess.html
@@ -86,6 +88,59 @@ module Subprocess
86
88
  output
87
89
  end
88
90
 
91
+ # Print a human readable interpretation of a process exit status.
92
+ #
93
+ # @param [::Process::Status] status The status returned by `waitpid2`.
94
+ # @param [Boolean] convert_high_exit Whether to convert exit statuses greater
95
+ # than 128 into the usual convention for exiting after trapping a signal.
96
+ # (e.g. many programs will exit with status 130 after receiving a SIGINT /
97
+ # signal 2.)
98
+ # @return [String] Text interpretation
99
+ #
100
+ def self.status_to_s(status, convert_high_exit=true)
101
+
102
+ # use an array just in case we somehow get a status with all the bits set
103
+ parts = []
104
+ if status.exited?
105
+ parts << "exited with status #{status.exitstatus}"
106
+ if convert_high_exit && status.exitstatus > 128
107
+ # convert high exit statuses into what the original signal may have
108
+ # been according to the usual exit status convention
109
+ sig_num = status.exitstatus - 128
110
+
111
+ # sigh, why is ruby so silly
112
+ begin
113
+ # ruby 2.0 way
114
+ sig_name = Signal.signame(sig_num)
115
+ rescue NoMethodError
116
+ begin
117
+ # ruby 1.9 way
118
+ sig_name = Signal.list.key(sig_num)
119
+ rescue NoMethodError
120
+ # ruby 1.8 way
121
+ sig_name = Signal.list.index(sig_num)
122
+ end
123
+ end
124
+
125
+ if sig_name
126
+ parts << "(maybe SIG#{sig_name})"
127
+ end
128
+ end
129
+ end
130
+ if status.signaled?
131
+ parts << "killed by signal #{status.termsig}"
132
+ end
133
+ if status.stopped?
134
+ parts << "stopped by signal #{status.stopsig}"
135
+ end
136
+
137
+ if parts.empty?
138
+ raise ArgumentError.new("Don't know how to interpret #{status.inspect}")
139
+ end
140
+
141
+ parts.join(', ')
142
+ end
143
+
89
144
  # Error class representing a process's abnormal exit.
90
145
  class NonZeroExit < StandardError
91
146
  # @!attribute [r] command
@@ -0,0 +1,3 @@
1
+ module Subprocess
2
+ VERSION = '1.0.0'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subprocess
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.16'
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-09-30 00:00:00.000000000 Z
16
+ date: 2013-10-19 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: minitest
@@ -31,6 +31,38 @@ dependencies:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5.0'
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ requirement: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ type: :development
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ - !ruby/object:Gem::Dependency
51
+ name: pry
52
+ requirement: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
34
66
  description: Control and communicate with spawned processes
35
67
  email:
36
68
  - carl@stripe.com
@@ -43,6 +75,7 @@ extensions: []
43
75
  extra_rdoc_files: []
44
76
  files:
45
77
  - lib/subprocess.rb
78
+ - lib/subprocess/version.rb
46
79
  - README.md
47
80
  homepage: https://github.com/stripe/subprocess
48
81
  licenses:
@@ -57,12 +90,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
90
  - - ! '>='
58
91
  - !ruby/object:Gem::Version
59
92
  version: '0'
93
+ segments:
94
+ - 0
95
+ hash: 84211792966870882
60
96
  required_rubygems_version: !ruby/object:Gem::Requirement
61
97
  none: false
62
98
  requirements:
63
99
  - - ! '>='
64
100
  - !ruby/object:Gem::Version
65
101
  version: '0'
102
+ segments:
103
+ - 0
104
+ hash: 84211792966870882
66
105
  requirements: []
67
106
  rubyforge_project:
68
107
  rubygems_version: 1.8.23
@@ -70,4 +109,3 @@ signing_key:
70
109
  specification_version: 3
71
110
  summary: A port of Python's subprocess module to Ruby
72
111
  test_files: []
73
- has_rdoc: