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.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/lib/cheetah.rb +22 -7
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ffad6048946bc9340bf92edbc08b4955a2444da86ed5c029bcf3a2f5b799f78
|
4
|
+
data.tar.gz: d3fc65ea30218372099bf81ab8ab86d4c5a2eb5314faac7c972c5518f910331c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff33b7ccf7423baf8c8158287be0efd1ad184069a6542f0d945fa493ea04c2a43c98b84e4e6e50f54d119ddb09575cddd0780fdaa7676fff3f9e839539db591c
|
7
|
+
data.tar.gz: f930f40f3eac5de9c611061ea0c3844d47e4c3475a392f4cfb74a3fe4350519eaca35e57eda0a9ef9fead81157d90b2967c14943b599e9d456220ee68a42b72c
|
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.2
|
data/lib/cheetah.rb
CHANGED
@@ -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
|
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/
|
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/
|
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
|
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
|
-
|
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.
|
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:
|
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
|
-
|
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
|