gofer 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Revision History
2
2
 
3
+ ### v0.2.0 03/05/2011
4
+
5
+ * Flip ordering of username/hostname on instantiation to match that of Net::SSH
6
+
3
7
  ### v0.1.2 03/05/2011
4
8
 
5
9
  * Pass through Gofer::Host instantiation options straight through to Net::SSH.
data/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ### Instantiation
16
16
 
17
- h = Gofer::Host.new('ubuntu', 'my.host.com', :keys => ['key.pem'])
17
+ h = Gofer::Host.new('my.host.com', 'ubuntu', :keys => ['key.pem'])
18
18
 
19
19
  ### Run a command
20
20
 
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 username, _hostname, opts={}
16
+ def initialize _hostname, username, opts={}
17
17
  @hostname = _hostname
18
- @ssh = SshWrapper.new(username, hostname, opts)
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+.
@@ -6,23 +6,8 @@ module Gofer
6
6
 
7
7
  attr_reader :last_output, :last_exit_status
8
8
 
9
- def initialize username, hostname, opts={}
10
- @username = username
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(*net_ssh_credentials)
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
@@ -1,3 +1,3 @@
1
1
  module Gofer # :nodoc:
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -30,7 +30,7 @@ describe Gofer do
30
30
  end
31
31
 
32
32
  before :all do
33
- @host = Gofer::Host.new(USERNAME, HOSTNAME, :keys => [IDENTITY_FILE])
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(USERNAME, HOSTNAME, IDENTITY_FILE).run("echo hello", :quiet => true).should == "hello\n"
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(USERNAME, HOSTNAME, :identity_file => IDENTITY_FILE).run("echo hello", :quiet => true).should == "hello\n"
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
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gofer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Pearson