gofer 0.1.0 → 0.1.1
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/.gitignore +1 -0
- data/HISTORY.md +4 -0
- data/lib/gofer.rb +3 -0
- data/lib/gofer/host.rb +21 -2
- data/lib/gofer/response.rb +2 -0
- data/lib/gofer/ssh_wrapper.rb +1 -1
- data/lib/gofer/version.rb +2 -2
- metadata +2 -2
data/.gitignore
CHANGED
data/HISTORY.md
CHANGED
data/lib/gofer.rb
CHANGED
data/lib/gofer/host.rb
CHANGED
@@ -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
|
data/lib/gofer/response.rb
CHANGED
data/lib/gofer/ssh_wrapper.rb
CHANGED
data/lib/gofer/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Gofer
|
2
|
-
VERSION = "0.1.
|
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.
|
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-
|
13
|
+
date: 2011-04-23 00:00:00 +10:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|