Exit_Zero 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Exit_Zero/version.rb +1 -1
- data/lib/Exit_Zero.rb +7 -7
- data/spec/tests/Exit_Zero.rb +6 -1
- metadata +14 -14
data/lib/Exit_Zero/version.rb
CHANGED
data/lib/Exit_Zero.rb
CHANGED
@@ -2,9 +2,9 @@ require 'Exit_Zero/version'
|
|
2
2
|
require 'Split_Lines'
|
3
3
|
require 'posix/spawn'
|
4
4
|
|
5
|
-
def Exit_Zero cmd
|
5
|
+
def Exit_Zero *cmd, &blok
|
6
6
|
|
7
|
-
both = cmd
|
7
|
+
both = !cmd.empty? && block_given?
|
8
8
|
raise ArgumentError, "Both command and block are not allowed." if both
|
9
9
|
|
10
10
|
if block_given?
|
@@ -12,8 +12,8 @@ def Exit_Zero cmd=:no_cmd, &blok
|
|
12
12
|
r = p = blok.call
|
13
13
|
msg = cmd
|
14
14
|
else
|
15
|
-
r = p = Exit_Zero::Child.new(cmd)
|
16
|
-
msg = p.err.strip.empty? ? cmd : p.err
|
15
|
+
r = p = Exit_Zero::Child.new(*cmd)
|
16
|
+
msg = p.err.strip.empty? ? p.cmd : p.err
|
17
17
|
end
|
18
18
|
|
19
19
|
(r = r.status) if r.respond_to?(:status)
|
@@ -37,9 +37,9 @@ class Exit_Zero
|
|
37
37
|
module Base
|
38
38
|
|
39
39
|
attr_reader :cmd, :child
|
40
|
-
def initialize cmd
|
41
|
-
@
|
42
|
-
@
|
40
|
+
def initialize *cmd
|
41
|
+
@child = POSIX::Spawn::Child.new(*cmd)
|
42
|
+
@cmd = cmd.join(' ')
|
43
43
|
end
|
44
44
|
|
45
45
|
def split_lines
|
data/spec/tests/Exit_Zero.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
|
2
|
-
describe "Exit_Zero
|
2
|
+
describe "Exit_Zero *cmd" do
|
3
3
|
|
4
|
+
it "accepts the same arguments as POSIX::Spawn::Child" do
|
5
|
+
Exit_Zero("dc", :input=>'4 4 + p').out
|
6
|
+
.should == "8\n"
|
7
|
+
end
|
8
|
+
|
4
9
|
it "raises Exit_Zero::Non_Zero if command exits with non-zero" do
|
5
10
|
lambda {
|
6
11
|
Exit_Zero 'uptimes'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Exit_Zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
16
|
-
requirement: &
|
16
|
+
requirement: &9668840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9668840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &9668400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9668400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Bacon_Colored
|
38
|
-
requirement: &
|
38
|
+
requirement: &9667920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *9667920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: pry
|
49
|
-
requirement: &
|
49
|
+
requirement: &9667400 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *9667400
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: Split_Lines
|
60
|
-
requirement: &
|
60
|
+
requirement: &9666920 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *9666920
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: posix-spawn
|
71
|
-
requirement: &
|
71
|
+
requirement: &9666400 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *9666400
|
80
80
|
description: ! "\n A simple method that raises Exit_Zero::Non_Zero\n if $?.exitstatus
|
81
81
|
is not zero.\n Be sure to use the \"posix-spawn\" since almost everything \n
|
82
82
|
\ else is just plain wrong when handling child processes.\n "
|