gofer 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +4 -0
- data/README.md +4 -3
- data/lib/gofer/host.rb +4 -1
- data/lib/gofer/ssh_wrapper.rb +1 -0
- data/lib/gofer/version.rb +1 -1
- data/spec/gofer/integration_spec.rb +3 -2
- metadata +2 -2
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
### Respond to command errors
|
38
38
|
|
39
|
-
h.run "false" # this will
|
39
|
+
h.run "false" # this will raise an error
|
40
40
|
response = h.run "false", :capture_exit_status => true # this won't ...
|
41
41
|
puts response.exit_status # and will make the exit status available
|
42
42
|
|
@@ -50,8 +50,9 @@
|
|
50
50
|
|
51
51
|
### Suppress output
|
52
52
|
|
53
|
-
h.run "echo noisy", :quiet => true
|
54
|
-
h.run "echo noisier 1>&2", :quiet_stderr => true # don't
|
53
|
+
h.run "echo noisy", :quiet => true # don't print stdout
|
54
|
+
h.run "echo noisier 1>&2", :quiet_stderr => true # don't print stderr
|
55
|
+
h.quiet = true # never print stdout
|
55
56
|
|
56
57
|
## Planned Features
|
57
58
|
|
data/lib/gofer/host.rb
CHANGED
@@ -8,6 +8,7 @@ module Gofer
|
|
8
8
|
class Host
|
9
9
|
|
10
10
|
attr_reader :hostname
|
11
|
+
attr_accessor :quiet
|
11
12
|
|
12
13
|
# Create a new Host connection
|
13
14
|
#
|
@@ -15,6 +16,7 @@ module Gofer
|
|
15
16
|
# See http://net-ssh.github.com/ssh/v2/api/index.html for valid arguments.
|
16
17
|
def initialize _hostname, username, opts={}
|
17
18
|
@hostname = _hostname
|
19
|
+
@quiet = false
|
18
20
|
|
19
21
|
# support legacy positional argument use
|
20
22
|
if opts.is_a? String
|
@@ -39,10 +41,11 @@ module Gofer
|
|
39
41
|
#
|
40
42
|
# Options:
|
41
43
|
#
|
42
|
-
# +quiet+:: Don't print +stdout+
|
44
|
+
# +quiet+:: Don't print +stdout+, can also be set with +quiet=+ on the instance
|
43
45
|
# +quiet_stderr+:: Don't print +stderr+
|
44
46
|
# +capture_exit_status+:: Don't raise an error on a non-zero exit status
|
45
47
|
def run command, opts={}
|
48
|
+
opts[:quiet] = quiet unless opts.include?(:quiet)
|
46
49
|
response = @ssh.run command, opts
|
47
50
|
if !opts[:capture_exit_status] && response.exit_status != 0
|
48
51
|
raise HostError.new(self, "Command #{command} failed with exit status #{@ssh.last_exit_status}")
|
data/lib/gofer/ssh_wrapper.rb
CHANGED
data/lib/gofer/version.rb
CHANGED
@@ -31,6 +31,7 @@ describe Gofer do
|
|
31
31
|
|
32
32
|
before :all do
|
33
33
|
@host = Gofer::Host.new(HOSTNAME, USERNAME, :keys => [IDENTITY_FILE])
|
34
|
+
@host.quiet = true
|
34
35
|
@tmpdir = raw_ssh("mktemp -d /tmp/gofertest.XXXXX").chomp
|
35
36
|
end
|
36
37
|
|
@@ -61,7 +62,7 @@ describe Gofer do
|
|
61
62
|
describe :run do
|
62
63
|
describe "with stdout and stderr responses" do
|
63
64
|
before :all do
|
64
|
-
@response = @host.run "echo stdout; echo stderr 1>&2", :
|
65
|
+
@response = @host.run "echo stdout; echo stderr 1>&2", :quiet_stderr => true
|
65
66
|
end
|
66
67
|
|
67
68
|
it "should capture stdout in @response.stdout" do
|
@@ -80,7 +81,7 @@ describe Gofer do
|
|
80
81
|
@response.should == "stdout\n"
|
81
82
|
end
|
82
83
|
end
|
83
|
-
|
84
|
+
|
84
85
|
it "should error if a command returns a non-zero response" do
|
85
86
|
lambda {@host.run "false"}.should raise_error /failed with exit status/
|
86
87
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael Pearson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-08 00:00:00 +10:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|