rye 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +7 -0
- data/README.rdoc +2 -0
- data/bin/rye +1 -0
- data/lib/rye.rb +8 -6
- data/lib/rye/box.rb +1 -1
- data/rye.gemspec +8 -47
- metadata +29 -52
- data/bin/try +0 -201
- data/lib/sys.rb +0 -302
- data/try/copying.rb +0 -18
- data/try/keys.rb +0 -141
- data/tst/10-key1 +0 -27
- data/tst/10-key1.pub +0 -1
- data/tst/10-key2 +0 -30
- data/tst/10-key2.pub +0 -1
- data/tst/10_keys_test.rb +0 -88
- data/tst/50_rset_test.rb +0 -54
- data/tst/60-file.mp3 +0 -0
- data/tst/60_rbox_transfer_test.rb +0 -53
- data/tst/70_rbox_env_test.rb +0 -19
- data/vendor/highline-1.5.1/CHANGELOG +0 -222
- data/vendor/highline-1.5.1/INSTALL +0 -35
- data/vendor/highline-1.5.1/LICENSE +0 -7
- data/vendor/highline-1.5.1/README +0 -63
- data/vendor/highline-1.5.1/Rakefile +0 -82
- data/vendor/highline-1.5.1/TODO +0 -6
- data/vendor/highline-1.5.1/examples/ansi_colors.rb +0 -38
- data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +0 -18
- data/vendor/highline-1.5.1/examples/basic_usage.rb +0 -75
- data/vendor/highline-1.5.1/examples/color_scheme.rb +0 -32
- data/vendor/highline-1.5.1/examples/limit.rb +0 -12
- data/vendor/highline-1.5.1/examples/menus.rb +0 -65
- data/vendor/highline-1.5.1/examples/overwrite.rb +0 -19
- data/vendor/highline-1.5.1/examples/page_and_wrap.rb +0 -322
- data/vendor/highline-1.5.1/examples/password.rb +0 -7
- data/vendor/highline-1.5.1/examples/trapping_eof.rb +0 -22
- data/vendor/highline-1.5.1/examples/using_readline.rb +0 -17
- data/vendor/highline-1.5.1/lib/highline.rb +0 -758
- data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +0 -120
- data/vendor/highline-1.5.1/lib/highline/compatibility.rb +0 -17
- data/vendor/highline-1.5.1/lib/highline/import.rb +0 -43
- data/vendor/highline-1.5.1/lib/highline/menu.rb +0 -395
- data/vendor/highline-1.5.1/lib/highline/question.rb +0 -463
- data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +0 -193
- data/vendor/highline-1.5.1/setup.rb +0 -1360
- data/vendor/highline-1.5.1/test/tc_color_scheme.rb +0 -56
- data/vendor/highline-1.5.1/test/tc_highline.rb +0 -823
- data/vendor/highline-1.5.1/test/tc_import.rb +0 -54
- data/vendor/highline-1.5.1/test/tc_menu.rb +0 -429
- data/vendor/highline-1.5.1/test/ts_all.rb +0 -15
data/CHANGES.txt
CHANGED
@@ -6,6 +6,13 @@ TODO
|
|
6
6
|
* Fingerprints: ssh-keygen -l -f id_rsa_repos.pub
|
7
7
|
|
8
8
|
|
9
|
+
#### 0.6.5 (2009-05-10) #############################
|
10
|
+
|
11
|
+
* CHANGE: Default exit code is now 0 instead of -1
|
12
|
+
* CHANGE: Removed Sys (using sysinfo gem)
|
13
|
+
* CHANGE: Removed vendor/highline-1.5.1 (it's now available via gem)
|
14
|
+
|
15
|
+
|
9
16
|
#### 0.6.4 (2009-05-04) #############################
|
10
17
|
|
11
18
|
* FIXED: authorize_remote was not returning to the directory it started with.
|
data/README.rdoc
CHANGED
data/bin/rye
CHANGED
data/lib/rye.rb
CHANGED
@@ -3,17 +3,19 @@
|
|
3
3
|
# a the issue with Ruby 1.9 that causes the prompts to hang.
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'vendor', 'highline-1.5.1', 'lib')
|
5
5
|
|
6
|
-
require 'tempfile'
|
7
6
|
require 'logger'
|
7
|
+
require 'thread'
|
8
|
+
require 'base64'
|
8
9
|
require 'net/ssh'
|
9
10
|
require 'net/scp'
|
10
|
-
require 'thread'
|
11
|
-
require 'highline'
|
12
11
|
require 'openssl'
|
13
|
-
require '
|
12
|
+
require 'tempfile'
|
13
|
+
require 'highline'
|
14
|
+
|
15
|
+
require 'storable'
|
16
|
+
require 'sysinfo'
|
14
17
|
|
15
18
|
require 'esc'
|
16
|
-
require 'sys'
|
17
19
|
|
18
20
|
# = Rye
|
19
21
|
#
|
@@ -45,7 +47,7 @@ module Rye
|
|
45
47
|
|
46
48
|
unless defined?(SYSINFO)
|
47
49
|
VERSION = 0.6.freeze
|
48
|
-
SYSINFO =
|
50
|
+
SYSINFO = SysInfo.new.freeze
|
49
51
|
end
|
50
52
|
|
51
53
|
@@agent_env = Hash.new # holds ssh-agent env vars
|
data/lib/rye/box.rb
CHANGED
@@ -597,7 +597,7 @@ module Rye
|
|
597
597
|
block ||= Proc.new do |channel, type, data|
|
598
598
|
channel[:stdout] ||= ""
|
599
599
|
channel[:stderr] ||= ""
|
600
|
-
channel[:exit_code] ||=
|
600
|
+
channel[:exit_code] ||= 0
|
601
601
|
channel[:stdout] << data if type == :stdout
|
602
602
|
channel[:stderr] << data if type == :stderr
|
603
603
|
channel.on_request("exit-status") do |ch, data|
|
data/rye.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "rye"
|
3
3
|
s.rubyforge_project = "rye"
|
4
|
-
s.version = "0.6.
|
4
|
+
s.version = "0.6.5"
|
5
5
|
s.summary = "Rye: Safely run SSH commands on a bunch of machines at the same time (from Ruby)."
|
6
6
|
s.description = s.summary
|
7
7
|
s.author = "Delano Mandelbaum"
|
@@ -10,10 +10,14 @@
|
|
10
10
|
|
11
11
|
# = DEPENDENCIES =
|
12
12
|
# Add all gem dependencies
|
13
|
-
s.add_dependency 'net-ssh'
|
14
|
-
s.add_dependency 'net-scp'
|
15
|
-
s.add_dependency 'highline'
|
16
13
|
s.add_dependency 'drydock'
|
14
|
+
s.add_dependency 'highline', '>= 1.5.1'
|
15
|
+
s.add_dependency 'sysinfo', '>= 0.5.1'
|
16
|
+
s.add_dependency 'storable', '>= 0.5.1'
|
17
|
+
s.add_dependency 'net-ssh', '>= 2.0.9'
|
18
|
+
s.add_dependency 'net-scp', '>= 1.0.2'
|
19
|
+
#s.add_dependency 'net-ssh-gateway'
|
20
|
+
#s.add_dependency 'net-ssh-multi'
|
17
21
|
|
18
22
|
# = EXECUTABLES =
|
19
23
|
# The list of executables in your project (if any). Don't include the path,
|
@@ -32,7 +36,6 @@
|
|
32
36
|
README.rdoc
|
33
37
|
Rakefile
|
34
38
|
bin/rye
|
35
|
-
bin/try
|
36
39
|
lib/esc.rb
|
37
40
|
lib/rye.rb
|
38
41
|
lib/rye/box.rb
|
@@ -40,49 +43,7 @@
|
|
40
43
|
lib/rye/key.rb
|
41
44
|
lib/rye/rap.rb
|
42
45
|
lib/rye/set.rb
|
43
|
-
lib/sys.rb
|
44
46
|
rye.gemspec
|
45
|
-
try/copying.rb
|
46
|
-
try/keys.rb
|
47
|
-
tst/10-key1
|
48
|
-
tst/10-key1.pub
|
49
|
-
tst/10-key2
|
50
|
-
tst/10-key2.pub
|
51
|
-
tst/10_keys_test.rb
|
52
|
-
tst/50_rset_test.rb
|
53
|
-
tst/60-file.mp3
|
54
|
-
tst/60_rbox_transfer_test.rb
|
55
|
-
tst/70_rbox_env_test.rb
|
56
|
-
vendor/highline-1.5.1/CHANGELOG
|
57
|
-
vendor/highline-1.5.1/INSTALL
|
58
|
-
vendor/highline-1.5.1/LICENSE
|
59
|
-
vendor/highline-1.5.1/README
|
60
|
-
vendor/highline-1.5.1/Rakefile
|
61
|
-
vendor/highline-1.5.1/TODO
|
62
|
-
vendor/highline-1.5.1/examples/ansi_colors.rb
|
63
|
-
vendor/highline-1.5.1/examples/asking_for_arrays.rb
|
64
|
-
vendor/highline-1.5.1/examples/basic_usage.rb
|
65
|
-
vendor/highline-1.5.1/examples/color_scheme.rb
|
66
|
-
vendor/highline-1.5.1/examples/limit.rb
|
67
|
-
vendor/highline-1.5.1/examples/menus.rb
|
68
|
-
vendor/highline-1.5.1/examples/overwrite.rb
|
69
|
-
vendor/highline-1.5.1/examples/page_and_wrap.rb
|
70
|
-
vendor/highline-1.5.1/examples/password.rb
|
71
|
-
vendor/highline-1.5.1/examples/trapping_eof.rb
|
72
|
-
vendor/highline-1.5.1/examples/using_readline.rb
|
73
|
-
vendor/highline-1.5.1/lib/highline.rb
|
74
|
-
vendor/highline-1.5.1/lib/highline/color_scheme.rb
|
75
|
-
vendor/highline-1.5.1/lib/highline/compatibility.rb
|
76
|
-
vendor/highline-1.5.1/lib/highline/import.rb
|
77
|
-
vendor/highline-1.5.1/lib/highline/menu.rb
|
78
|
-
vendor/highline-1.5.1/lib/highline/question.rb
|
79
|
-
vendor/highline-1.5.1/lib/highline/system_extensions.rb
|
80
|
-
vendor/highline-1.5.1/setup.rb
|
81
|
-
vendor/highline-1.5.1/test/tc_color_scheme.rb
|
82
|
-
vendor/highline-1.5.1/test/tc_highline.rb
|
83
|
-
vendor/highline-1.5.1/test/tc_import.rb
|
84
|
-
vendor/highline-1.5.1/test/tc_menu.rb
|
85
|
-
vendor/highline-1.5.1/test/ts_all.rb
|
86
47
|
)
|
87
48
|
|
88
49
|
s.extra_rdoc_files = %w[README.rdoc LICENSE.txt]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-20 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: drydock
|
17
17
|
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -23,34 +23,54 @@ dependencies:
|
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: highline
|
27
27
|
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.5.1
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: sysinfo
|
37
37
|
type: :runtime
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 0.5.1
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
46
|
+
name: storable
|
47
47
|
type: :runtime
|
48
48
|
version_requirement:
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 0.5.1
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-ssh
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.0.9
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: net-scp
|
67
|
+
type: :runtime
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 1.0.2
|
54
74
|
version:
|
55
75
|
description: "Rye: Safely run SSH commands on a bunch of machines at the same time (from Ruby)."
|
56
76
|
email: delano@solutious.com
|
@@ -67,7 +87,6 @@ files:
|
|
67
87
|
- README.rdoc
|
68
88
|
- Rakefile
|
69
89
|
- bin/rye
|
70
|
-
- bin/try
|
71
90
|
- lib/esc.rb
|
72
91
|
- lib/rye.rb
|
73
92
|
- lib/rye/box.rb
|
@@ -75,49 +94,7 @@ files:
|
|
75
94
|
- lib/rye/key.rb
|
76
95
|
- lib/rye/rap.rb
|
77
96
|
- lib/rye/set.rb
|
78
|
-
- lib/sys.rb
|
79
97
|
- rye.gemspec
|
80
|
-
- try/copying.rb
|
81
|
-
- try/keys.rb
|
82
|
-
- tst/10-key1
|
83
|
-
- tst/10-key1.pub
|
84
|
-
- tst/10-key2
|
85
|
-
- tst/10-key2.pub
|
86
|
-
- tst/10_keys_test.rb
|
87
|
-
- tst/50_rset_test.rb
|
88
|
-
- tst/60-file.mp3
|
89
|
-
- tst/60_rbox_transfer_test.rb
|
90
|
-
- tst/70_rbox_env_test.rb
|
91
|
-
- vendor/highline-1.5.1/CHANGELOG
|
92
|
-
- vendor/highline-1.5.1/INSTALL
|
93
|
-
- vendor/highline-1.5.1/LICENSE
|
94
|
-
- vendor/highline-1.5.1/README
|
95
|
-
- vendor/highline-1.5.1/Rakefile
|
96
|
-
- vendor/highline-1.5.1/TODO
|
97
|
-
- vendor/highline-1.5.1/examples/ansi_colors.rb
|
98
|
-
- vendor/highline-1.5.1/examples/asking_for_arrays.rb
|
99
|
-
- vendor/highline-1.5.1/examples/basic_usage.rb
|
100
|
-
- vendor/highline-1.5.1/examples/color_scheme.rb
|
101
|
-
- vendor/highline-1.5.1/examples/limit.rb
|
102
|
-
- vendor/highline-1.5.1/examples/menus.rb
|
103
|
-
- vendor/highline-1.5.1/examples/overwrite.rb
|
104
|
-
- vendor/highline-1.5.1/examples/page_and_wrap.rb
|
105
|
-
- vendor/highline-1.5.1/examples/password.rb
|
106
|
-
- vendor/highline-1.5.1/examples/trapping_eof.rb
|
107
|
-
- vendor/highline-1.5.1/examples/using_readline.rb
|
108
|
-
- vendor/highline-1.5.1/lib/highline.rb
|
109
|
-
- vendor/highline-1.5.1/lib/highline/color_scheme.rb
|
110
|
-
- vendor/highline-1.5.1/lib/highline/compatibility.rb
|
111
|
-
- vendor/highline-1.5.1/lib/highline/import.rb
|
112
|
-
- vendor/highline-1.5.1/lib/highline/menu.rb
|
113
|
-
- vendor/highline-1.5.1/lib/highline/question.rb
|
114
|
-
- vendor/highline-1.5.1/lib/highline/system_extensions.rb
|
115
|
-
- vendor/highline-1.5.1/setup.rb
|
116
|
-
- vendor/highline-1.5.1/test/tc_color_scheme.rb
|
117
|
-
- vendor/highline-1.5.1/test/tc_highline.rb
|
118
|
-
- vendor/highline-1.5.1/test/tc_import.rb
|
119
|
-
- vendor/highline-1.5.1/test/tc_menu.rb
|
120
|
-
- vendor/highline-1.5.1/test/ts_all.rb
|
121
98
|
has_rdoc: true
|
122
99
|
homepage: http://solutious.com/
|
123
100
|
licenses: []
|
data/bin/try
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
# Rye -- A working example
|
4
|
-
#
|
5
|
-
# If your reading this via the rdocs you won't be able to see the code
|
6
|
-
# See: http://github.com/delano/rye/blob/master/bin/try
|
7
|
-
#
|
8
|
-
# Usage: bin/try
|
9
|
-
#
|
10
|
-
|
11
|
-
RYE_HOME = File.join(File.dirname(__FILE__), '..')
|
12
|
-
$:.unshift File.join(RYE_HOME, 'lib')
|
13
|
-
|
14
|
-
require 'stringio'
|
15
|
-
require 'yaml'
|
16
|
-
require 'rye'
|
17
|
-
|
18
|
-
|
19
|
-
puts %Q(
|
20
|
-
# ------------------------------------------------------------------
|
21
|
-
# EXAMPLE 1 -- Basic Usage
|
22
|
-
#)
|
23
|
-
|
24
|
-
rbox = Rye::Box.new('localhost')
|
25
|
-
|
26
|
-
# Commands are run as methods on the Rye::Box object
|
27
|
-
puts rbox.uptime # => 11:02 up 16:01, 3 users
|
28
|
-
|
29
|
-
# The response value for all commands is a Rye::Rap object. The rap is a
|
30
|
-
# subclass of Array so you can treat it as an Array, but it can also act
|
31
|
-
# like a String if there's only one element.
|
32
|
-
p rbox.ls(:a, '/') # => ['.', '..', 'bin', 'etc', ...]
|
33
|
-
|
34
|
-
# You can change directories
|
35
|
-
puts rbox.pwd # => /home/rye
|
36
|
-
puts rbox['/usr/bin'].pwd # => /usr/bin
|
37
|
-
puts rbox.pwd # => /usr/bin
|
38
|
-
|
39
|
-
# You can specify environment variables
|
40
|
-
rbox.setenv(:RYE, "Forty Creek")
|
41
|
-
rbox.env # => ['HOME=/home/rye', 'RYE=Forty Creek', ...]
|
42
|
-
|
43
|
-
# The commands method returns an Array of available commands:
|
44
|
-
puts rbox.commands.join(', ') # => pwd, touch, echo, wc, ...
|
45
|
-
|
46
|
-
# When you're done you can disconnect explicitly.
|
47
|
-
# (Although Rye does this automatically at exit.)
|
48
|
-
rbox.disconnect
|
49
|
-
|
50
|
-
|
51
|
-
puts %Q(
|
52
|
-
# ------------------------------------------------------------------
|
53
|
-
# EXAMPLE 2 -- Disabling Safe-Mode
|
54
|
-
#)
|
55
|
-
|
56
|
-
rbox_safe = Rye::Box.new('localhost')
|
57
|
-
rbox_wild = Rye::Box.new('localhost', :safe => false)
|
58
|
-
|
59
|
-
# Safe-mode is enabled by default. In safe-mode, all command
|
60
|
-
# arguments are thoroughly escaped. This prevents access to
|
61
|
-
# environment variables and file globs (among other things).
|
62
|
-
p rbox_safe.echo('$HOME') # => "$HOME"
|
63
|
-
p rbox_safe['/etc'].ls('host*') rescue Rye::CommandError # Doesn't exist
|
64
|
-
p rbox_safe.ls('-l | wc -l') rescue Rye::CommandError # => '|' is not a valid ls arg
|
65
|
-
|
66
|
-
# Here's the same commands with safe-mode disabled:
|
67
|
-
p rbox_wild.echo('$HOME') # => "/home/rye"
|
68
|
-
p rbox_wild['/etc'].ls('host*') # => ["hostconfig", "hosts"]
|
69
|
-
p rbox_wild.ls('-l | wc -l') # => 110
|
70
|
-
p rbox_wild.echo('$HOME > /tmp/rye-home') # =>
|
71
|
-
p rbox_wild.cat('/tmp/rye-home') # => "/home/rye"
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
puts %Q(
|
76
|
-
# ------------------------------------------------------------------
|
77
|
-
# EXAMPLE 3 -- Custom Commands
|
78
|
-
#)
|
79
|
-
|
80
|
-
rbox = Rye::Box.new('localhost')
|
81
|
-
rbox.add_keys('/private/key/path') # Specify additional private keys
|
82
|
-
|
83
|
-
# There's currently no rye900 command
|
84
|
-
p rbox.commands.member?('rye9000') # => false
|
85
|
-
|
86
|
-
# But we can add our own commands to the Rye::Cmd class. They
|
87
|
-
# automatically become available to all Rye::Box objects.
|
88
|
-
module Rye::Cmd
|
89
|
-
def rye9000(*args)
|
90
|
-
run_command("ls", args)
|
91
|
-
end
|
92
|
-
def somescript(*args)
|
93
|
-
run_command("/path/to/my/script", args)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# We can now run rye9000 (with arguments)
|
98
|
-
p rbox.rye9000('-a') # => [".", "..", ".bashrc", ...]
|
99
|
-
p rbox.commands.member?('rye9000') # => true
|
100
|
-
|
101
|
-
|
102
|
-
puts %Q(
|
103
|
-
# ------------------------------------------------------------------
|
104
|
-
# EXAMPLE 4 -- Accessing Multiple Machines
|
105
|
-
#)
|
106
|
-
|
107
|
-
rset = Rye::Set.new('default', :parallel => true)
|
108
|
-
rbox = Rye::Box.new
|
109
|
-
p rbox
|
110
|
-
|
111
|
-
rset.add_keys('/private/key/path') # For passwordless logins
|
112
|
-
rset.add_boxes(rbox, '127.0.0.1') # Add boxes as hostnames or objects
|
113
|
-
|
114
|
-
# Calling methods on Rye::Set objects is very similar to calling them on
|
115
|
-
# Rye::Box objects. In fact, it's identical:
|
116
|
-
p rset.uptime # => [[14:19:02 up 32 days, 19:35 ...], [14:19:02 up 30 days, 01:35]]
|
117
|
-
p rset['/usr'].ls # => [['bin', 'etc', ...], ['bin', 'etc', ...]]
|
118
|
-
|
119
|
-
# Like Rye::Box, the response value is a Rye::Rap object containing the
|
120
|
-
# responses from each box. Each response is itself a Rye::Rap object.
|
121
|
-
unames = rset.uname
|
122
|
-
p unames # => [["Darwin"], ["Darwin"]]
|
123
|
-
puts unames.class # => Rye::Rap
|
124
|
-
|
125
|
-
# The Rye::Rap object also keeps a reference to the object that called the
|
126
|
-
# command. In this case, it will keep a reference to Rye::Set:
|
127
|
-
puts unames.set.class # => Rye::Set
|
128
|
-
puts unames.set == rset # => true
|
129
|
-
puts unames.size # => 2
|
130
|
-
puts unames.first # => Darwin
|
131
|
-
puts unames.first.class # => Rye::Rap
|
132
|
-
puts unames.first.box.class # => Rye::Box
|
133
|
-
puts unames.first.box == rbox # => true
|
134
|
-
|
135
|
-
# Envrionment variables can be set the same way as with Rye::Box
|
136
|
-
rset.setenv(:RYE, "Forty Creek")
|
137
|
-
p rset.env.first.select { |env| env =~ /RYE/ } # => ["RYE=Forty Creek"]
|
138
|
-
|
139
|
-
|
140
|
-
puts %Q(
|
141
|
-
# ------------------------------------------------------------------
|
142
|
-
# EXAMPLE 5 -- ERROR HANDLING
|
143
|
-
#)
|
144
|
-
|
145
|
-
rbox = Rye::Box.new('localhost', :safe => false) # Note: safe mode is off
|
146
|
-
|
147
|
-
# Rye follows the standard convention of taking exception to a non-zero
|
148
|
-
# exit code by raising a Rye::CommandError. In this case, rye9000.test
|
149
|
-
# is not found by the ls command.
|
150
|
-
begin
|
151
|
-
rbox.ls('rye.test')
|
152
|
-
rescue Rye::CommandError => ex
|
153
|
-
puts ex.exit_code # => 1
|
154
|
-
puts ex.stderr # => ls: rye.test: No such file or directory
|
155
|
-
end
|
156
|
-
|
157
|
-
# The Rye:Rap response objects also give you the STDOUT and STDERR
|
158
|
-
# content separately. Here we redirect STDOUT to STDERR, so this
|
159
|
-
# will return nothing:
|
160
|
-
puts rbox.uname('-a 1>&2').stdout # =>
|
161
|
-
|
162
|
-
# It all went to STDERR:
|
163
|
-
puts rbox.uname('-a 1>&2').stderr # => Darwin ryehost 9.6.0 ...
|
164
|
-
|
165
|
-
# There were no actual errors so the exit code should be 0.
|
166
|
-
puts rbox.uname('-a 1>&2').exit_code # => 0
|
167
|
-
|
168
|
-
|
169
|
-
puts %Q(
|
170
|
-
# ------------------------------------------------------------------
|
171
|
-
# EXAMPLE 6 -- FILE TRANSFERS
|
172
|
-
#)
|
173
|
-
|
174
|
-
dir_upload = "#{Rye.sysinfo.tmpdir}/rye-upload/"
|
175
|
-
dir_download = "#{Rye.sysinfo.tmpdir}/rye-download/"
|
176
|
-
|
177
|
-
rbox = Rye::Box.new("localhost", :info => false)
|
178
|
-
|
179
|
-
# Rye ships without an rm method (for safety!). Here
|
180
|
-
# we add the rm method only to this instance of rbox.
|
181
|
-
def rbox.rm(*args); cmd('rm', args); end
|
182
|
-
|
183
|
-
rbox.rm(:r, :f, dir_upload) # Silently delete test dirs
|
184
|
-
rbox.rm(:r, :f, dir_download)
|
185
|
-
|
186
|
-
rbox.upload("#{RYE_HOME}/README.rdoc",
|
187
|
-
"#{RYE_HOME}/LICENSE.txt", dir_upload)
|
188
|
-
|
189
|
-
applejack = StringIO.new("Some in-memory content")
|
190
|
-
rbox.upload(applejack, "#{dir_upload}/applejack.txt")
|
191
|
-
|
192
|
-
p rbox.ls(dir_upload) # => [README.rdoc, LICENSE.txt, applejack.txt]
|
193
|
-
p rbox.cat("#{dir_upload}/applejack.txt") # => "Some in-memory content"
|
194
|
-
|
195
|
-
filecontent = StringIO.new
|
196
|
-
rbox.download("#{dir_upload}/applejack.txt", filecontent)
|
197
|
-
filecontent.rewind
|
198
|
-
p filecontent.read
|
199
|
-
|
200
|
-
|
201
|
-
|