gofer 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.md +4 -0
- data/README.md +1 -1
- data/lib/gofer/host.rb +13 -2
- data/lib/gofer/ssh_wrapper.rb +3 -23
- data/lib/gofer/version.rb +1 -1
- data/spec/gofer/integration_spec.rb +3 -3
- metadata +1 -1
data/HISTORY.md
CHANGED
data/README.md
CHANGED
data/lib/gofer/host.rb
CHANGED
@@ -13,9 +13,20 @@ module Gofer
|
|
13
13
|
#
|
14
14
|
# +opts+ is passed through directly to Net::SSH.start
|
15
15
|
# See http://net-ssh.github.com/ssh/v2/api/index.html for valid arguments.
|
16
|
-
def initialize
|
16
|
+
def initialize _hostname, username, opts={}
|
17
17
|
@hostname = _hostname
|
18
|
-
|
18
|
+
|
19
|
+
# support legacy positional argument use
|
20
|
+
if opts.is_a? String
|
21
|
+
opts = { :keys => [opts]}
|
22
|
+
end
|
23
|
+
|
24
|
+
# support legacy identity_file argument
|
25
|
+
if opts[:identity_file]
|
26
|
+
opts[:keys] = [opts.delete(:identity_file)]
|
27
|
+
end
|
28
|
+
|
29
|
+
@ssh = SshWrapper.new(hostname, username, opts)
|
19
30
|
end
|
20
31
|
|
21
32
|
# Run +command+.
|
data/lib/gofer/ssh_wrapper.rb
CHANGED
@@ -6,23 +6,8 @@ module Gofer
|
|
6
6
|
|
7
7
|
attr_reader :last_output, :last_exit_status
|
8
8
|
|
9
|
-
def initialize
|
10
|
-
@
|
11
|
-
@hostname = hostname
|
12
|
-
@last_exit_status = nil
|
13
|
-
@last_output = nil
|
14
|
-
|
15
|
-
# support legacy positional argument use
|
16
|
-
if opts.is_a? String
|
17
|
-
opts = { :keys => [opts]}
|
18
|
-
end
|
19
|
-
|
20
|
-
# support legacy identity_file argument
|
21
|
-
if opts[:identity_file]
|
22
|
-
opts[:keys] = [opts.delete(:identity_file)]
|
23
|
-
end
|
24
|
-
|
25
|
-
@net_ssh_options = opts
|
9
|
+
def initialize *args
|
10
|
+
@net_ssh_args = args
|
26
11
|
end
|
27
12
|
|
28
13
|
def run command, opts={}
|
@@ -44,18 +29,13 @@ module Gofer
|
|
44
29
|
private
|
45
30
|
|
46
31
|
def ssh
|
47
|
-
@ssh ||= Net::SSH.start(
|
32
|
+
@ssh ||= Net::SSH.start(*@net_ssh_args)
|
48
33
|
end
|
49
34
|
|
50
35
|
def scp
|
51
36
|
@scp ||= Net::SCP.new(ssh)
|
52
37
|
end
|
53
38
|
|
54
|
-
def net_ssh_credentials
|
55
|
-
creds = [@hostname, @username, @net_ssh_options]
|
56
|
-
creds
|
57
|
-
end
|
58
|
-
|
59
39
|
def ssh_execute(ssh, command, opts={})
|
60
40
|
stdout, stderr, output = '', '', ''
|
61
41
|
exit_code = 0
|
data/lib/gofer/version.rb
CHANGED
@@ -30,7 +30,7 @@ describe Gofer do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
before :all do
|
33
|
-
@host = Gofer::Host.new(
|
33
|
+
@host = Gofer::Host.new(HOSTNAME, USERNAME, :keys => [IDENTITY_FILE])
|
34
34
|
@tmpdir = raw_ssh("mktemp -d /tmp/gofertest.XXXXX").chomp
|
35
35
|
end
|
36
36
|
|
@@ -44,11 +44,11 @@ describe Gofer do
|
|
44
44
|
|
45
45
|
describe :new do
|
46
46
|
it "should support the legacy positional argument" do
|
47
|
-
Gofer::Host.new(
|
47
|
+
Gofer::Host.new(HOSTNAME, USERNAME, IDENTITY_FILE).run("echo hello", :quiet => true).should == "hello\n"
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should support the legacy identity_file key" do
|
51
|
-
Gofer::Host.new(
|
51
|
+
Gofer::Host.new(HOSTNAME, USERNAME, :identity_file => IDENTITY_FILE).run("echo hello", :quiet => true).should == "hello\n"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|