ridley 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,37 +3,30 @@ module Ridley
3
3
  # A Ruby platform agnostic way of executing shell commands on the local system
4
4
  module ShellOut
5
5
  class Response
6
- extend Forwardable
7
-
6
+ # @return [Fixnum]
7
+ attr_reader :exitstatus
8
8
  # @return [String]
9
9
  attr_reader :stdout
10
10
  # @return [String]
11
11
  attr_reader :stderr
12
12
 
13
- def_delegator :process_status, :exitstatus
14
- def_delegator :process_status, :pid
15
- def_delegator :process_status, :success?
16
- def_delegator :process_status, :exited?
17
- def_delegator :process_status, :stopped?
18
-
19
- # @param [Process::Status] process_status
13
+ # @param [Fixnum] exitstatus
20
14
  # @param [String] stdout
21
15
  # @param [String] stderr
22
- def initialize(process_status, stdout, stderr)
23
- @process_status = process_status
24
- @stdout = stdout
25
- @stderr = stderr
16
+ def initialize(exitstatus, stdout, stderr)
17
+ @exitstatus = exitstatus
18
+ @stdout = stdout
19
+ @stderr = stderr
20
+ end
21
+
22
+ def success?
23
+ exitstatus == 0
26
24
  end
27
25
 
28
26
  def error?
29
27
  !success?
30
28
  end
31
29
  alias_method :failure?, :error?
32
-
33
- private
34
-
35
- # @return [Process::Status]
36
- attr_reader :process_status
37
30
  end
38
31
 
39
32
  include Chozo::RubyEngine
@@ -58,9 +51,11 @@ module Ridley
58
51
  out, err = Tempfile.new('ridley.shell_out.stdout'), Tempfile.new('ridley.shell_out.stderr')
59
52
 
60
53
  begin
61
- pid = Process.spawn(command, out: out.to_i, err: err.to_i)
62
- Process.waitpid(pid)
63
- rescue Errno::ENOENT
54
+ pid = Process.spawn(command, out: out.to_i, err: err.to_i)
55
+ pid, status = Process.waitpid2(pid)
56
+ exitstatus = status.exitstatus
57
+ rescue Errno::ENOENT => ex
58
+ exitstatus = 127
64
59
  out.write("")
65
60
  err.write("command not found: #{command}")
66
61
  end
@@ -68,7 +63,7 @@ module Ridley
68
63
  out.close
69
64
  err.close
70
65
 
71
- [ $?, File.read(out), File.read(err) ]
66
+ [ exitstatus, File.read(out), File.read(err) ]
72
67
  end
73
68
 
74
69
  # @param [String] command
@@ -1,3 +1,3 @@
1
1
  module Ridley
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -13,7 +13,6 @@ describe Ridley::Mixin::ShellOut do
13
13
  its(:stdout) { should be_a(String) }
14
14
  its(:stderr) { should be_a(String) }
15
15
  its(:exitstatus) { should be_a(Fixnum) }
16
- its(:pid) { should be_a(Fixnum) }
17
16
  its(:success?) { should be_true }
18
17
  its(:error?) { should be_false }
19
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridley
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-07 00:00:00.000000000 Z
13
+ date: 2013-06-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -390,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
390
390
  version: '0'
391
391
  segments:
392
392
  - 0
393
- hash: -3032546146925818617
393
+ hash: 2826734640182789390
394
394
  requirements: []
395
395
  rubyforge_project:
396
396
  rubygems_version: 1.8.23