qbash 0.0.5 → 0.0.6

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
  SHA256:
3
- metadata.gz: 629198be7c8f09f07807f2fdc3f43b771df5d1b97ef33ae3a827c1d56a9ec98c
4
- data.tar.gz: f7b85be41ea296b819d13e3f4cb23f9d0bfb8137de8f05cd6f10737e535c68a7
3
+ metadata.gz: ddc357961a48953ee7c479583b6d648d9ad34873510e7ef6d8096a7bd8e596b5
4
+ data.tar.gz: 16dfe814c412365131380e239a93e90532419ece6e66fb3ce0c74bf6566cae5b
5
5
  SHA512:
6
- metadata.gz: 026321cb7140203439059803f02a305980c5c44b988c9ebab82522eb8ede41d9d45dad8c6b1d312fcf7a9ae2192cabd2a67b7305e98d8836fd25d5276ceb6a48
7
- data.tar.gz: fd16b90f2af7f1a8ff116e0c1d95cc66a760e4c6c74fcc2763990d9ccf8b07517b6886277e81c8e18164db4c794ac7b619f5df98a20eed888b36fc0fbd300423
6
+ metadata.gz: 15ae921b000efb256d6907b1b69cda9e60a63612d25eccab76b09f0c765d6aa9d1337ed43580b3bf18cfd84a73e69b4f16aaad62065c8df9644a87779c0d8485
7
+ data.tar.gz: 6de449a43159e54803266ca16cb960bd09772abbb9a33ad3b5fa77fa25be63cef6e38fa0edb003c342e2c495bfd37b98035365aa76a9a2b9271d99385498ac96
data/README.md CHANGED
@@ -32,6 +32,9 @@ stdout = qbash('echo "Hello, world!"', log: $stdout)
32
32
 
33
33
  If the command fails, an exception will be raised.
34
34
 
35
+ The function automatically merges `stderr` with `stdout`
36
+ (you can't change this).
37
+
35
38
  It's possible to provide the standard input and environment variables:
36
39
 
37
40
  ```ruby
data/lib/qbash.rb CHANGED
@@ -34,17 +34,23 @@ require 'tago'
34
34
  module Kernel
35
35
  # Execute a single bash command.
36
36
  #
37
+ # For example:
38
+ #
39
+ # year = qbash('date +%Y')
40
+ #
37
41
  # If exit code is not zero, an exception will be raised.
38
42
  #
39
43
  # To escape arguments, use +Shellwords.escape()+ method.
40
44
  #
45
+ # Stderr automatically merges with stdout.
46
+ #
41
47
  # Read this <a href="https://github.com/yegor256/qbash">README</a> file for more details.
42
48
  #
43
49
  # @param [String] cmd The command to run, for example +echo "Hello, world!"+
44
50
  # @param [String] stdin The +stdin+ to provide to the command
45
51
  # @param [Hash] env Hash of environment variables
46
52
  # @param [Loog|IO] log Logging facility with +.debug()+ method (or +$stdout+)
47
- # @param [Array] accept List of accepted exit codes (accepts all if the list is empty)
53
+ # @param [Array] accept List of accepted exit codes (accepts all if the list is +nil+)
48
54
  # @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
49
55
  # @param [Integer] timeout If it's set to non-NIL, the execution will fail after this number of seconds
50
56
  # @return [String] Everything that was printed to the +stdout+ by the command
@@ -77,7 +83,7 @@ module Kernel
77
83
  buf += ln
78
84
  end
79
85
  e = thr.value.to_i
80
- if !accept.empty? && !accept.include?(e)
86
+ if !accept.nil? && !accept.include?(e)
81
87
  raise "The command '#{cmd}' failed with exit code ##{e} in #{start.ago}\n#{buf}"
82
88
  end
83
89
  end
data/qbash.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
27
27
  s.required_ruby_version = '>=3.2'
28
28
  s.name = 'qbash'
29
- s.version = '0.0.5'
29
+ s.version = '0.0.6'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Quick Executor of a BASH Command'
32
32
  s.description =
data/test/test_qbash.rb CHANGED
@@ -75,13 +75,13 @@ class TestQbash < Minitest::Test
75
75
 
76
76
  def test_ignore_errors
77
77
  Dir.mktmpdir do |home|
78
- qbash("cat #{Shellwords.escape(File.join(home, 'b.txt'))}", accept: [])
78
+ qbash("cat #{Shellwords.escape(File.join(home, 'b.txt'))}", accept: nil)
79
79
  end
80
80
  end
81
81
 
82
82
  def test_with_both
83
83
  Dir.mktmpdir do |home|
84
- stdout, code = qbash("cat #{Shellwords.escape(File.join(home, 'foo.txt'))}", accept: [], both: true)
84
+ stdout, code = qbash("cat #{Shellwords.escape(File.join(home, 'foo.txt'))}", accept: nil, both: true)
85
85
  assert(code.positive?)
86
86
  assert(!stdout.empty?)
87
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qbash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-02 00:00:00.000000000 Z
11
+ date: 2024-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace