sheller 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sheller.rb +10 -8
- data/test/sheller_test.rb +5 -0
- data/test/test_helper.rb +1 -1
- metadata +4 -4
data/lib/sheller.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'popen4'
|
2
2
|
|
3
3
|
module Sheller
|
4
|
-
VERSION = '0.0.
|
4
|
+
VERSION = '0.0.4'
|
5
5
|
|
6
6
|
INESCAPABLE = {}
|
7
7
|
|
@@ -30,11 +30,12 @@ module Sheller
|
|
30
30
|
|
31
31
|
def execute(*args)
|
32
32
|
stdout, stderr = nil
|
33
|
-
|
33
|
+
shell_command = command(*args)
|
34
|
+
status = POpen4.popen4(shell_command) do |_stdout, _stderr, _stdin, _pid|
|
34
35
|
stdout = _stdout.read
|
35
36
|
stderr = _stderr.read
|
36
37
|
end
|
37
|
-
ShellerResult.new(stdout, stderr, status)
|
38
|
+
ShellerResult.new(stdout, stderr, status, shell_command)
|
38
39
|
end
|
39
40
|
|
40
41
|
private
|
@@ -54,12 +55,13 @@ module Sheller
|
|
54
55
|
end
|
55
56
|
|
56
57
|
class ShellerResult
|
57
|
-
attr_reader 'stdout', 'stderr', 'exit_status'
|
58
|
+
attr_reader 'stdout', 'stderr', 'exit_status', 'command'
|
58
59
|
|
59
|
-
def initialize(stdout, stderr, exit_status)
|
60
|
-
@stdout
|
61
|
-
@stderr
|
60
|
+
def initialize(stdout, stderr, exit_status, command)
|
61
|
+
@stdout = stdout
|
62
|
+
@stderr = stderr
|
62
63
|
@exit_status = exit_status
|
64
|
+
@command = command
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
data/test/sheller_test.rb
CHANGED
@@ -89,4 +89,9 @@ class ShellerTest < Test::Unit::TestCase
|
|
89
89
|
result = Sheller.execute('grep', 'Dublin', Sheller::STDIN_FROM_FILE, './fixtures/cities.txt')
|
90
90
|
assert_equal "Dublin\n", result.stdout
|
91
91
|
end
|
92
|
+
|
93
|
+
def test_command
|
94
|
+
result = Sheller.execute('echo', 'barnacle')
|
95
|
+
assert_equal "'echo' 'barnacle'", result.command
|
96
|
+
end
|
92
97
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sheller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Duncan Beevers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|