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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 966719c9586242b7332ade84478e11e320e4ae98
4
- data.tar.gz: b64c492f89dd399c2197c2edb8f4725911dc9fc4
3
+ metadata.gz: dac1e6b00a41e6783110d9a9fc96da71fd5ab61c
4
+ data.tar.gz: 8831f8d4596d34ea1142074170147baf080bfaeb
5
5
  SHA512:
6
- metadata.gz: c9939dbe6aa70fd5c9ff9192574115991ad8721182e6472c112eb8f2229cf59575ecc0a5f0d43c2084dfc2bb97e10dd7324f3d242427fada36b75443d12d750c
7
- data.tar.gz: 5279d553623bd90792f97e0dda4245d9095daa8b8022f038ec42014b25bf94632075907832386c02f3bce80e75966bf8c72286b0534156869c774cc4f1d84a49
6
+ metadata.gz: 540109394d1a586ba812d347769e39b65481ce4ac616cc78100a383db5c318ff214599c0cdf107d5edff6bb183b657154285793468f7d3a0ce4055383106bd1c
7
+ data.tar.gz: ab5b802c207e303928e984ef64de2cef779b4f46f68fb52de72d6946dad814b8bd6e06ae54c30c84c55f447a877a32ed7d6e0b4993470db5c1760bd65e427030
data/.travis.yml CHANGED
@@ -3,5 +3,8 @@ sudo: false
3
3
  addons:
4
4
  code_climate:
5
5
  repo_token: e7445c267f016d1a041c9cd16889fa806714e9a7c9bc1fc7936465442b9a167b
6
+ before_install:
7
+ - gem update --remote bundler
8
+ - gem update --system
6
9
  after_success:
7
10
  - bundle exec codeclimate-test-reporter
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
@@ -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.3'.freeze
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
@@ -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.3'
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.3
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