qbash 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39338c15ddd4926d63fda7043f8f1037e0b6c6d6796e2e40a40e5d184963fdd1
4
- data.tar.gz: 1198126dc03e798b35ba5a22499e48efdbd29fe477c9386b694687c0be1d60ed
3
+ metadata.gz: 83183014aa9cde18aa4c0924665c2f1d18940d4f4ff64a66602a0ba973aa1aa0
4
+ data.tar.gz: 69881b928dbf2526c9e89542620d27d1cc90ffde48dd369ed2dfbe4051c0e724
5
5
  SHA512:
6
- metadata.gz: 2c91c96828249e4f4116e322fc08b07fb75acef2d2c6a1e102cf9440c0e5f12a91d609ddb69969f7cf079293cb7d1b56242853f049935dc895f5e4536693e80d
7
- data.tar.gz: 32ae547117a5ee567dc4cd488b9c54264975c6705d56798654e06bf8d150a7da52b5a30e94d508d986252784890abdcc81de36a80238bf3d85835aee5f786bd9
6
+ metadata.gz: c4800029b521eb3372ca256ccb874b816207d589753977ede31afb293b9922e7ab477057fdeaca94aa435e0e8ecb47a677fd2e6be39c14a7aacbd0f14aad1d07
7
+ data.tar.gz: 0d87c04e4f0e2d85b1208da0824161d6c720a39268e1e3838791d2776b41a331c0f6086429d680ddf1c46429db4b2fb3e211aeac50ef175c9804057a491b6db9
data/lib/qbash.rb CHANGED
@@ -50,7 +50,7 @@ module Kernel
50
50
  # @param [String] cmd The command to run, for example +echo "Hello, world!"+
51
51
  # @param [String] stdin The +stdin+ to provide to the command
52
52
  # @param [Hash] env Hash of environment variables
53
- # @param [Loog|IO] log Logging facility with +.debug()+ method (or +$stdout+)
53
+ # @param [Loog|IO] log Logging facility with +.debug()+ method (or +$stdout+, or nil if should go to +/dev/null+)
54
54
  # @param [Array] accept List of accepted exit codes (accepts all if the list is +nil+)
55
55
  # @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
56
56
  # @param [Integer] level Logging level (use +Logger::DEBUG+, +Logger::INFO+, +Logger::WARN+, or +Logger::ERROR+)
@@ -71,7 +71,9 @@ module Kernel
71
71
  else
72
72
  raise "Unknown log level #{level}"
73
73
  end
74
- if log.respond_to?(mtd)
74
+ if log.nil?
75
+ # nothing to print
76
+ elsif log.respond_to?(mtd)
75
77
  log.__send__(mtd, "+ #{cmd}")
76
78
  else
77
79
  log.print("+ #{cmd}\n")
@@ -90,7 +92,9 @@ module Kernel
90
92
  rescue IOError => e
91
93
  ln = Backtrace.new(e).to_s
92
94
  end
93
- if log.respond_to?(mtd)
95
+ if log.nil?
96
+ # no logging
97
+ elsif log.respond_to?(mtd)
94
98
  log.__send__(mtd, ln)
95
99
  else
96
100
  log.print("#{ln}\n")
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.2.1'
29
+ s.version = '0.2.2'
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
@@ -59,6 +59,10 @@ class TestQbash < Minitest::Test
59
59
  assert_equal('Hi!', qbash(['printf', nil, 'Hi!', '']))
60
60
  end
61
61
 
62
+ def test_log_to_nil
63
+ assert_equal("yes\n", qbash('echo yes', log: nil))
64
+ end
65
+
62
66
  def test_accept_zero
63
67
  qbash('echo hi', accept: nil)
64
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qbash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko