cheetah 0.5.1 → 0.5.2

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +7 -0
  3. data/VERSION +1 -1
  4. data/lib/cheetah.rb +22 -7
  5. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3e79228df3ba4822704c7f3e81fe0fdbec93a7a36f7935d2b117380470be1ed
4
- data.tar.gz: f398f8b357f85c2c7cf8f08a790bb77f586e1d251eba4eea0d97ea940e651517
3
+ metadata.gz: 7ffad6048946bc9340bf92edbc08b4955a2444da86ed5c029bcf3a2f5b799f78
4
+ data.tar.gz: d3fc65ea30218372099bf81ab8ab86d4c5a2eb5314faac7c972c5518f910331c
5
5
  SHA512:
6
- metadata.gz: 06fbed837fee79bbf04be03355c8c339df1ffdf9d3f005743f6bcc7896a2c4a604a53f723e8cc2f95e6d07db4cd0b6ca105272ab0ac870b6d37d21baa15d4a38
7
- data.tar.gz: 1ef2088f550bf7d7bf4c3ea7369fdef6ea3e9a49b36d5f5666f6ddcf449663e484073eb85a47f47f9e5d14b89ba6da13ac7b0065852884fb7fcc7f848f631d11
6
+ metadata.gz: ff33b7ccf7423baf8c8158287be0efd1ad184069a6542f0d945fa493ea04c2a43c98b84e4e6e50f54d119ddb09575cddd0780fdaa7676fff3f9e839539db591c
7
+ data.tar.gz: f930f40f3eac5de9c611061ea0c3844d47e4c3475a392f4cfb74a3fe4350519eaca35e57eda0a9ef9fead81157d90b2967c14943b599e9d456220ee68a42b72c
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.5.2 (2020-01-06)
2
+ ------------------
3
+
4
+ * If listed in allowed_exitstatus, log exit code as Info, not as Error
5
+ (bsc#1153749)
6
+ * Added support for ruby 2.7
7
+
1
8
  0.5.1 (2019-10-16)
2
9
  ------------------
3
10
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -402,8 +402,12 @@ module Cheetah
402
402
  select_loop(streams, pipes, recorder)
403
403
  _pid, status = Process.wait2(pid)
404
404
 
405
+ # when more exit status are allowed, then redefine success as command
406
+ # not failed (bsc#1153749)
407
+ adapt_status(status, options)
408
+
405
409
  begin
406
- check_errors(commands, status, streams, streamed, options)
410
+ check_errors(commands, status, streams, streamed)
407
411
  ensure
408
412
  recorder.record_status(status)
409
413
  end
@@ -413,6 +417,14 @@ module Cheetah
413
417
 
414
418
  private
415
419
 
420
+ def adapt_status(status, options)
421
+ return unless allowed_exitstatus?(options)
422
+
423
+ status.define_singleton_method(:success?) do
424
+ options[:allowed_exitstatus].include?(exitstatus)
425
+ end
426
+ end
427
+
416
428
  # Parts of Cheetah.run
417
429
 
418
430
  def with_env(env, &block)
@@ -558,7 +570,7 @@ module Cheetah
558
570
  next if (0..2).include?(fd)
559
571
 
560
572
  # here we intentionally ignore some failures when fd close failed
561
- # rubocop:disable Lint/HandleExceptions
573
+ # rubocop:disable Lint/SuppressedException
562
574
  begin
563
575
  IO.new(fd).close
564
576
  # Ruby reserves some fds for its VM and it result in this exception
@@ -566,7 +578,7 @@ module Cheetah
566
578
  # Ignore if close failed with invalid FD
567
579
  rescue Errno::EBADF
568
580
  end
569
- # rubocop:enable Lint/HandleExceptions
581
+ # rubocop:enable Lint/SuppressedException
570
582
  end
571
583
  end
572
584
 
@@ -643,9 +655,8 @@ module Cheetah
643
655
  end
644
656
  end
645
657
 
646
- def check_errors(commands, status, streams, streamed, options)
658
+ def check_errors(commands, status, streams, streamed)
647
659
  return if status.success?
648
- return if options[:allowed_exitstatus].include?(status.exitstatus)
649
660
 
650
661
  stderr_part = if streamed[:stderr]
651
662
  " (error output streamed away)"
@@ -678,8 +689,7 @@ module Cheetah
678
689
  [streams[:stdout].string, streams[:stderr].string]
679
690
  end
680
691
 
681
- # do not capture only for empty array or nil converted to empty array
682
- if !options[:allowed_exitstatus].is_a?(Array) || !options[:allowed_exitstatus].empty?
692
+ if allowed_exitstatus?(options)
683
693
  if res.nil?
684
694
  res = status.exitstatus
685
695
  else
@@ -691,6 +701,11 @@ module Cheetah
691
701
  res
692
702
  end
693
703
 
704
+ def allowed_exitstatus?(options)
705
+ # more exit status allowed for non array or non empty array
706
+ !options[:allowed_exitstatus].is_a?(Array) || !options[:allowed_exitstatus].empty?
707
+ end
708
+
694
709
  def format_commands(commands)
695
710
  '"' + commands.map { |c| Shellwords.join(c) }.join(" | ") + '"'
696
711
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheetah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Majda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-17 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_method
@@ -84,7 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.0.3
87
+ rubyforge_project:
88
+ rubygems_version: 2.7.6.2
88
89
  signing_key:
89
90
  specification_version: 4
90
91
  summary: Your swiss army knife for executing external commands in Ruby safely and