Exit_0 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Exit_0.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Make sure your last child process exited with 0.}
13
13
  s.description = %q{
14
14
  A simple method that runs a child process and raises
15
- Exit_Zero::Non_Zero if $?.exitstatus is not zero.
15
+ Exit_0::Non_0 if $?.exitstatus is not zero.
16
16
  }
17
17
 
18
18
  s.files = `git ls-files`.split("\n")
data/lib/Exit_0.rb CHANGED
@@ -2,6 +2,19 @@ require 'Exit_0/version'
2
2
  require 'Split_Lines'
3
3
  require 'posix/spawn'
4
4
 
5
+ module Kernel
6
+
7
+ private
8
+
9
+ def exit_0 cmd
10
+ new = Split_Lines(cmd).join(' && ')
11
+ o = `#{new} 2>&1`.strip
12
+ raise Exit_0::Non_0, "#{$?.exitstatus} => #{o}" unless $?.exitstatus == 0
13
+ o
14
+ end
15
+
16
+ end # === Kernel
17
+
5
18
  def Exit_0 *cmd, &blok
6
19
 
7
20
  both = !cmd.empty? && block_given?
@@ -1,3 +1,3 @@
1
1
  class Exit_0
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -0,0 +1,37 @@
1
+
2
+
3
+
4
+ describe "exit_0 String" do
5
+
6
+
7
+ it "raises Exit_0::Non_0 if command exits with non-0" do
8
+ lambda {
9
+ exit_0 '
10
+ uptimes
11
+ '
12
+ }.should.raise(Exit_0::Non_0)
13
+ .message.should.match %r!127 => sh: 1: uptimes: not found!
14
+ end
15
+
16
+ it "executes valid command" do
17
+ exit_0('pwd').should == `pwd`.strip
18
+ end
19
+
20
+ it "combines a multi-line string into one string, joined by \"&&\"" do
21
+ exit_0(%!
22
+ cd ~/
23
+ pwd
24
+ !)
25
+ .should == `cd ~/ && pwd`.strip
26
+ end
27
+
28
+ it "ignores empty lines in a multi-line string" do
29
+ exit_0(%!
30
+ cd ~/
31
+
32
+ pwd
33
+ !).should == `cd ~/ && pwd`.strip
34
+ end
35
+
36
+ end # === Exit_0 'cmd'
37
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Exit_0
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-27 00:00:00.000000000 Z
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
@@ -123,7 +123,7 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
- description: ! "\n A simple method that runs a child process and raises\n Exit_Zero::Non_Zero
126
+ description: ! "\n A simple method that runs a child process and raises\n Exit_0::Non_0
127
127
  if $?.exitstatus is not zero.\n "
128
128
  email:
129
129
  - i-hate-spam-45671204@mailinator.com
@@ -144,6 +144,7 @@ files:
144
144
  - spec/tests/Exit_0.rb
145
145
  - spec/tests/Exit_Zero.rb
146
146
  - spec/tests/bin.rb
147
+ - spec/tests/exit_0.rb
147
148
  homepage: https://github.com/da99/Exit_0
148
149
  licenses: []
149
150
  post_install_message: