process_helper 0.0.4.pre.beta.3 → 0.0.4.pre.beta.4
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/.travis.yml +3 -0
- data/README.md +9 -0
- data/lib/process_helper.rb +5 -1
- data/process_helper.gemspec +1 -1
- data/spec/trace_handling_spec.rb +23 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dac1e6b00a41e6783110d9a9fc96da71fd5ab61c
|
4
|
+
data.tar.gz: 8831f8d4596d34ea1142074170147baf080bfaeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 540109394d1a586ba812d347769e39b65481ce4ac616cc78100a383db5c318ff214599c0cdf107d5edff6bb183b657154285793468f7d3a0ce4055383106bd1c
|
7
|
+
data.tar.gz: ab5b802c207e303928e984ef64de2cef779b4f46f68fb52de72d6946dad814b8bd6e06ae54c30c84c55f447a877a32ed7d6e0b4993470db5c1760bd65e427030
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -49,6 +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
|
+
* [`:trace` (short form `:t`)](#trace-short-form-t)
|
52
53
|
* [Warnings if failure output will be suppressed based on options](#warnings-if-failure-output-will-be-suppressed-based-on-options)
|
53
54
|
* [Version](#version)
|
54
55
|
* [Contributing](#contributing)
|
@@ -213,6 +214,14 @@ Valid value is a float, e.g. `1.5`. Default value is nil/undefined.
|
|
213
214
|
|
214
215
|
See [https://www.pivotaltracker.com/story/show/93303096](https://www.pivotaltracker.com/story/show/93303096) for more details.
|
215
216
|
|
217
|
+
### `:trace` (short form `:t`)
|
218
|
+
|
219
|
+
Valid value is a boolean. Default value is false.
|
220
|
+
|
221
|
+
* Prints command to STDOUT before it is executed.
|
222
|
+
* This is useful to have a "log" to know what commands are executing,
|
223
|
+
especially when using `puts_output: :error` or `puts_output: :never`,
|
224
|
+
and when the command might not finish immediately.
|
216
225
|
|
217
226
|
|
218
227
|
## Warnings if failure output will be suppressed based on options
|
data/lib/process_helper.rb
CHANGED
@@ -6,7 +6,7 @@ require 'stringio'
|
|
6
6
|
# Makes it easier to spawn ruby sub-processes with proper capturing of stdout and stderr streams.
|
7
7
|
module ProcessHelper
|
8
8
|
# Don't forget to keep version in sync with gemspec
|
9
|
-
VERSION = '0.0.4.pre.beta.
|
9
|
+
VERSION = '0.0.4.pre.beta.4'.freeze
|
10
10
|
|
11
11
|
# rubocop:disable Style/ModuleFunction
|
12
12
|
extend self
|
@@ -16,6 +16,7 @@ module ProcessHelper
|
|
16
16
|
fail ProcessHelper::EmptyCommandError, 'command must not be empty' if cmd.empty?
|
17
17
|
options = options.dup
|
18
18
|
options_processing(options)
|
19
|
+
puts cmd if options[:trace]
|
19
20
|
output, process_status =
|
20
21
|
if options[:pseudo_terminal]
|
21
22
|
process_with_pseudo_terminal(cmd, options)
|
@@ -175,6 +176,7 @@ module ProcessHelper
|
|
175
176
|
options[:pseudo_terminal] = false if options[:pseudo_terminal].nil?
|
176
177
|
options[:expected_exit_status] = [0] if options[:expected_exit_status].nil?
|
177
178
|
options[:input] = StringIO.new(options[:input].to_s) unless options[:input].is_a?(StringIO)
|
179
|
+
options[:trace] = false if options[:trace].nil?
|
178
180
|
end
|
179
181
|
|
180
182
|
def valid_option_pairs
|
@@ -185,6 +187,7 @@ module ProcessHelper
|
|
185
187
|
%w(pseudo_terminal pty),
|
186
188
|
%w(puts_output out),
|
187
189
|
%w(timeout kill),
|
190
|
+
%w(trace t),
|
188
191
|
]
|
189
192
|
pairs.each do |pair|
|
190
193
|
pair.each_with_index do |opt, index|
|
@@ -230,6 +233,7 @@ module ProcessHelper
|
|
230
233
|
validate_boolean(pair, value) if option.to_s == 'include_output_in_exception'
|
231
234
|
validate_boolean(pair, value) if option.to_s == 'pseudo_terminal'
|
232
235
|
validate_puts_output(pair, value) if option.to_s == 'puts_output'
|
236
|
+
validate_boolean(pair, value) if option.to_s == 'trace'
|
233
237
|
end
|
234
238
|
end
|
235
239
|
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.4'
|
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 /
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'trace handling' do
|
4
|
+
attr_reader :clazz
|
5
|
+
|
6
|
+
before do
|
7
|
+
@clazz = Clazz.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'prints command if trace is true' do
|
11
|
+
expect do
|
12
|
+
clazz.process('echo stdout > /dev/stdout', puts_output: :always, trace: true)
|
13
|
+
end.to output("echo stdout > /dev/stdout\nstdout\n").to_stdout
|
14
|
+
.and(not_output.to_stderr)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does not print command if trace is false' do
|
18
|
+
expect do
|
19
|
+
clazz.process('echo stdout > /dev/stdout', puts_output: :always, trace: false)
|
20
|
+
end.to output("stdout\n").to_stdout
|
21
|
+
.and(not_output.to_stderr)
|
22
|
+
end
|
23
|
+
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Woolley
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- spec/spec_helper.rb
|
156
156
|
- spec/static_analysis_spec.rb
|
157
157
|
- spec/timeout_handling_spec.rb
|
158
|
+
- spec/trace_handling_spec.rb
|
158
159
|
homepage: https://github.com/thewoolleyman/process_helper
|
159
160
|
licenses:
|
160
161
|
- Unlicense
|
@@ -193,3 +194,4 @@ test_files:
|
|
193
194
|
- spec/spec_helper.rb
|
194
195
|
- spec/static_analysis_spec.rb
|
195
196
|
- spec/timeout_handling_spec.rb
|
197
|
+
- spec/trace_handling_spec.rb
|