process_helper 0.0.4.pre.beta.4 → 0.0.4.pre.beta.5
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/process_helper.rb +10 -6
- data/process_helper.gemspec +1 -1
- data/spec/{trace_handling_spec.rb → log_cmd_handling_spec.rb} +5 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f03bf56af641f1950bc970aa466dbe9e02b651
|
4
|
+
data.tar.gz: 48875777e0c764098effc5e4441c55b794caf6d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c9dba3252d1b036d19c70ca73ab51ace44edaf1d05a58b71176dcad4f52af937413703aa88333ea8b03fc95aae6ceb83dffa1120dc143672c95f51f524c611
|
7
|
+
data.tar.gz: 4d39a694b203397a324fadc02cdce6267235f827efcef00bae5e3c6105aee4747f0fba65a39e33035b7bca99e9abaed9dc96469c9984e95bca48c17e1cc89d89
|
data/README.md
CHANGED
@@ -49,7 +49,7 @@ However, `process_helper` was created because none of them made it *easy* to run
|
|
49
49
|
* [`:pseudo_terminal` (short form `:pty`)](#pseudo_terminal-short-form-pty)
|
50
50
|
* [`:puts_output` (short form `:out`)](#puts_output-short-form-out)
|
51
51
|
* [`:timeout` (short form `:kill`)](#timeout-short-form-kill)
|
52
|
-
* [`:
|
52
|
+
* [`:log_cmd` (short form `:log`)](#log_cmd-short-form-log)
|
53
53
|
* [Warnings if failure output will be suppressed based on options](#warnings-if-failure-output-will-be-suppressed-based-on-options)
|
54
54
|
* [Version](#version)
|
55
55
|
* [Contributing](#contributing)
|
@@ -214,7 +214,7 @@ Valid value is a float, e.g. `1.5`. Default value is nil/undefined.
|
|
214
214
|
|
215
215
|
See [https://www.pivotaltracker.com/story/show/93303096](https://www.pivotaltracker.com/story/show/93303096) for more details.
|
216
216
|
|
217
|
-
### `:
|
217
|
+
### `:log_cmd` (short form `:log`)
|
218
218
|
|
219
219
|
Valid value is a boolean. Default value is false.
|
220
220
|
|
data/lib/process_helper.rb
CHANGED
@@ -3,10 +3,14 @@ require 'pty'
|
|
3
3
|
require 'timeout'
|
4
4
|
require 'stringio'
|
5
5
|
|
6
|
-
# Makes it
|
6
|
+
# Makes it easy to spawn Ruby sub-processes with guaranteed exit status handling,
|
7
|
+
# capturing and/or suppressing combined STDOUT and STDERR streams,
|
8
|
+
# providing STDIN input, timeouts, and running via a pseudo terminal.
|
9
|
+
#
|
10
|
+
# Full documentation at https://github.com/thewoolleyman/process_helper
|
7
11
|
module ProcessHelper
|
8
12
|
# Don't forget to keep version in sync with gemspec
|
9
|
-
VERSION = '0.0.4.pre.beta.
|
13
|
+
VERSION = '0.0.4.pre.beta.5'.freeze
|
10
14
|
|
11
15
|
# rubocop:disable Style/ModuleFunction
|
12
16
|
extend self
|
@@ -16,7 +20,7 @@ module ProcessHelper
|
|
16
20
|
fail ProcessHelper::EmptyCommandError, 'command must not be empty' if cmd.empty?
|
17
21
|
options = options.dup
|
18
22
|
options_processing(options)
|
19
|
-
puts cmd if options[:
|
23
|
+
puts cmd if options[:log_cmd]
|
20
24
|
output, process_status =
|
21
25
|
if options[:pseudo_terminal]
|
22
26
|
process_with_pseudo_terminal(cmd, options)
|
@@ -176,7 +180,7 @@ module ProcessHelper
|
|
176
180
|
options[:pseudo_terminal] = false if options[:pseudo_terminal].nil?
|
177
181
|
options[:expected_exit_status] = [0] if options[:expected_exit_status].nil?
|
178
182
|
options[:input] = StringIO.new(options[:input].to_s) unless options[:input].is_a?(StringIO)
|
179
|
-
options[:
|
183
|
+
options[:log_cmd] = false if options[:log_cmd].nil?
|
180
184
|
end
|
181
185
|
|
182
186
|
def valid_option_pairs
|
@@ -187,7 +191,7 @@ module ProcessHelper
|
|
187
191
|
%w(pseudo_terminal pty),
|
188
192
|
%w(puts_output out),
|
189
193
|
%w(timeout kill),
|
190
|
-
%w(
|
194
|
+
%w(log_cmd log),
|
191
195
|
]
|
192
196
|
pairs.each do |pair|
|
193
197
|
pair.each_with_index do |opt, index|
|
@@ -233,7 +237,7 @@ module ProcessHelper
|
|
233
237
|
validate_boolean(pair, value) if option.to_s == 'include_output_in_exception'
|
234
238
|
validate_boolean(pair, value) if option.to_s == 'pseudo_terminal'
|
235
239
|
validate_puts_output(pair, value) if option.to_s == 'puts_output'
|
236
|
-
validate_boolean(pair, value) if option.to_s == '
|
240
|
+
validate_boolean(pair, value) if option.to_s == 'log_cmd'
|
237
241
|
end
|
238
242
|
end
|
239
243
|
end
|
data/process_helper.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'process_helper'
|
5
5
|
# Don't forget to keep version in sync with ProcessHelper::Version
|
6
|
-
spec.version = '0.0.4.pre.beta.
|
6
|
+
spec.version = '0.0.4.pre.beta.5'
|
7
7
|
spec.authors = ['Chad Woolley', 'Glenn Oppegard']
|
8
8
|
spec.email = ['oppegard@gmail.com', 'thewoolleyman@gmail.com']
|
9
9
|
spec.summary = "Makes it easier to spawn ruby sub-processes with proper capturing /
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe '
|
3
|
+
RSpec.describe 'log command handling' do
|
4
4
|
attr_reader :clazz
|
5
5
|
|
6
6
|
before do
|
7
7
|
@clazz = Clazz.new
|
8
8
|
end
|
9
9
|
|
10
|
-
it 'prints command if
|
10
|
+
it 'prints command if log_cmd is true' do
|
11
11
|
expect do
|
12
|
-
clazz.process('echo stdout > /dev/stdout', puts_output: :always,
|
12
|
+
clazz.process('echo stdout > /dev/stdout', puts_output: :always, log_cmd: true)
|
13
13
|
end.to output("echo stdout > /dev/stdout\nstdout\n").to_stdout
|
14
14
|
.and(not_output.to_stderr)
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'does not print command if
|
17
|
+
it 'does not print command if log_cmd is false' do
|
18
18
|
expect do
|
19
|
-
clazz.process('echo stdout > /dev/stdout', puts_output: :always,
|
19
|
+
clazz.process('echo stdout > /dev/stdout', puts_output: :always, log_cmd: false)
|
20
20
|
end.to output("stdout\n").to_stdout
|
21
21
|
.and(not_output.to_stderr)
|
22
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: process_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.pre.beta.
|
4
|
+
version: 0.0.4.pre.beta.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Woolley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- ruby-lint.yml
|
146
146
|
- spec/error_handling_spec.rb
|
147
147
|
- spec/input_handling_spec.rb
|
148
|
+
- spec/log_cmd_handling_spec.rb
|
148
149
|
- spec/module_visibility_spec.rb
|
149
150
|
- spec/options/expected_exit_status_spec.rb
|
150
151
|
- spec/options/include_output_in_exception_spec.rb
|
@@ -155,7 +156,6 @@ files:
|
|
155
156
|
- spec/spec_helper.rb
|
156
157
|
- spec/static_analysis_spec.rb
|
157
158
|
- spec/timeout_handling_spec.rb
|
158
|
-
- spec/trace_handling_spec.rb
|
159
159
|
homepage: https://github.com/thewoolleyman/process_helper
|
160
160
|
licenses:
|
161
161
|
- Unlicense
|
@@ -184,6 +184,7 @@ summary: Makes it easier to spawn ruby sub-processes with proper capturing / of
|
|
184
184
|
test_files:
|
185
185
|
- spec/error_handling_spec.rb
|
186
186
|
- spec/input_handling_spec.rb
|
187
|
+
- spec/log_cmd_handling_spec.rb
|
187
188
|
- spec/module_visibility_spec.rb
|
188
189
|
- spec/options/expected_exit_status_spec.rb
|
189
190
|
- spec/options/include_output_in_exception_spec.rb
|
@@ -194,4 +195,3 @@ test_files:
|
|
194
195
|
- spec/spec_helper.rb
|
195
196
|
- spec/static_analysis_spec.rb
|
196
197
|
- spec/timeout_handling_spec.rb
|
197
|
-
- spec/trace_handling_spec.rb
|