gofer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  .bundle
4
4
  Gemfile.lock
5
5
  pkg/*
6
+ doc
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Revision History
2
2
 
3
+ ### v0.1.1 23/04/2011
4
+
5
+ * Minimal RDoc added.
6
+
3
7
  ### v0.1.0 20/04/2011
4
8
 
5
9
  * Replace string return from run with a 'response' object
@@ -3,3 +3,6 @@ require 'gofer/response'
3
3
  require 'gofer/host'
4
4
  require 'gofer/version'
5
5
 
6
+ # See Gofer::Host
7
+ module Gofer
8
+ end
@@ -1,12 +1,12 @@
1
1
  module Gofer
2
- class HostError < Exception
2
+ class HostError < Exception # :nodoc:
3
3
  def initialize host, message
4
4
  super "#{host.hostname}: #{message}"
5
5
  end
6
6
  end
7
7
 
8
8
  class Host
9
-
9
+
10
10
  attr_reader :hostname
11
11
 
12
12
  def initialize username, _hostname, identity_file=nil
@@ -14,6 +14,19 @@ module Gofer
14
14
  @ssh = SshWrapper.new(username, hostname, identity_file)
15
15
  end
16
16
 
17
+ # Run +command+.
18
+ #
19
+ # Raise an error if +command+ exits with a non-zero status.
20
+ #
21
+ # Print +stdout+ and +stderr+ as they're received.
22
+ #
23
+ # Return a Gofer::Response object.
24
+ #
25
+ # Options:
26
+ #
27
+ # +quiet+:: Don't print +stdout+
28
+ # +quiet_stderr+:: Don't print +stderr+
29
+ # +capture_exit_status+:: Don't raise an error on a non-zero exit status
17
30
  def run command, opts={}
18
31
  response = @ssh.run command, opts
19
32
  if !opts[:capture_exit_status] && response.exit_status != 0
@@ -22,18 +35,22 @@ module Gofer
22
35
  response
23
36
  end
24
37
 
38
+ # Return +true+ if +path+ exits.
25
39
  def exists? path
26
40
  @ssh.run("sh -c '[ -e #{path} ]'").exit_status == 0
27
41
  end
28
42
 
43
+ # Return the contents of the file at +path+.
29
44
  def read path
30
45
  @ssh.read_file path
31
46
  end
32
47
 
48
+ # Return +true+ if +path+ is a directory.
33
49
  def directory? path
34
50
  @ssh.run("sh -c '[ -d #{path} ]'").exit_status == 0
35
51
  end
36
52
 
53
+ # Return a list of files in the directory at +path+.
37
54
  def ls path
38
55
  response = @ssh.run "ls -1 #{path}", :quiet => true
39
56
  if response.exit_status == 0
@@ -43,10 +60,12 @@ module Gofer
43
60
  end
44
61
  end
45
62
 
63
+ # Upload the file or directory at +from+ to +to+.
46
64
  def upload from, to
47
65
  @ssh.upload from, to, :recursive => File.directory?(from)
48
66
  end
49
67
 
68
+ # Download the file or directory at +from+ to +to+
50
69
  def download from, to
51
70
  @ssh.download from, to, :recursive => directory?(from)
52
71
  end
@@ -1,4 +1,6 @@
1
1
  module Gofer
2
+
3
+ # Response container for the various outputs from Gofer::Host#run
2
4
  class Response < String
3
5
  attr_reader :stdout, :stderr, :output, :exit_status
4
6
 
@@ -2,7 +2,7 @@ require 'net/ssh'
2
2
  require 'net/scp'
3
3
 
4
4
  module Gofer
5
- class SshWrapper
5
+ class SshWrapper # :nodoc:
6
6
 
7
7
  attr_reader :last_output, :last_exit_status
8
8
 
@@ -1,3 +1,3 @@
1
- module Gofer
2
- VERSION = "0.1.0"
1
+ module Gofer # :nodoc:
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gofer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.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-04-20 00:00:00 +10:00
13
+ date: 2011-04-23 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency