rye 0.9.7 → 0.9.8

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.
@@ -0,0 +1,25 @@
1
+ $: << File.expand_path(Dir.pwd + "/lib")
2
+ $:.reverse!
3
+
4
+ require 'rubygems'
5
+ require 'rye'
6
+ begin
7
+ require 'perftools'
8
+ rescue LoadError => ex
9
+ puts ex.message
10
+ puts "$> gem install perftools.rb"
11
+ exit 1
12
+ end
13
+
14
+ data_file = Dir.pwd + "/profile.data"
15
+ pdf_file = Dir.pwd + "/profile.pdf"
16
+ text_file = Dir.pwd + "/profile.txt"
17
+
18
+ PerfTools::CpuProfiler.start(data_file) do
19
+ lo0 = Rye::Hop.new "localhost" # set some real host names
20
+ lo1 = Rye::Box.new "localhost", :via => lo0 # set some real host names
21
+ puts lo1.uptime
22
+ end
23
+
24
+ system("pprof.rb --pdf #{data_file} > #{pdf_file}")
25
+ system("pprof.rb --text #{data_file} > #{text_file}")
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Delano Mandelbaum
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
11
+ cert_chain:
12
+ - !binary |-
13
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROakNDQWg2Z0F3SUJB
14
+ Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJCTVE4d0RRWURWUVFEREFaa1pX
15
+ eGgKYm04eEdUQVhCZ29Ka2lhSmsvSXNaQUVaRmdsemIyeDFkR2x2ZFhNeEV6
16
+ QVJCZ29Ka2lhSmsvSXNaQUVaRmdOagpiMjB3SGhjTk1UTXdNakEyTVRFMU56
17
+ UTFXaGNOTVRRd01qQTJNV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2JtZnBDQWxwNS81ZwpwczR3UUZ5
34
+ NW1pYkVsR1ZsT29iZi9naHFaMjVIUzlKNmtkMC9DL3J5MEFVdFRvZ3NMN1R4
35
+ R3dUNGtiQ3g2M3ViCjN2eXdFRWhzSlV6ZmQ5N0dDQUJtdFFmUlRsZFgvajdG
36
+ MXovNXdkOHAraGZkb3gxaWliZHM5WnRmYVpBM0t6S24Ka2NoV045QjZ6Zzly
37
+ MVhNUThCTTJKejBYb1BhblBlMzU0K2xXd2pwa1JLYkZvdy9aYlFIY0NMQ3Ey
38
+ NCtONmI2ZwpkZ0tmTkR6d2lEcHFDQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
39
+ LS0tLS0K
40
+ date: 2013-02-06 00:00:00.000000000 Z
13
41
  dependencies:
14
42
  - !ruby/object:Gem::Dependency
15
43
  name: annoy
@@ -91,39 +119,79 @@ dependencies:
91
119
  - - ! '>='
92
120
  - !ruby/object:Gem::Version
93
121
  version: 1.0.2
94
- description: ! 'Rye: Safely run SSH commands on a bunch of machines at the same time
95
- (from Ruby).'
122
+ - !ruby/object:Gem::Dependency
123
+ name: docile
124
+ requirement: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: 1.0.1
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: 1.0.1
138
+ description: Run SSH commands on a bunch of machines at the same time (from Ruby).
96
139
  email: delano@solutious.com
97
140
  executables: []
98
141
  extensions: []
99
142
  extra_rdoc_files:
100
- - README.rdoc
101
143
  - LICENSE.txt
144
+ - README.rdoc
102
145
  files:
103
146
  - CHANGES.txt
104
147
  - LICENSE.txt
105
148
  - README.rdoc
106
149
  - Rakefile
107
150
  - Rudyfile
108
- - bin/try
151
+ - VERSION
152
+ - gem-public_cert.pem
109
153
  - lib/esc.rb
110
154
  - lib/rye.rb
111
155
  - lib/rye/box.rb
112
156
  - lib/rye/cmd.rb
157
+ - lib/rye/dsl.rb
158
+ - lib/rye/hop.rb
113
159
  - lib/rye/key.rb
114
160
  - lib/rye/rap.rb
115
161
  - lib/rye/set.rb
116
- - lib/rye/hop.rb
117
162
  - rye.gemspec
118
- homepage: http://github.com/delano/rye/
163
+ - try/10_basic_tryouts.rb
164
+ - try/12_batch_tryouts.rb
165
+ - try/13_set_tryouts.rb
166
+ - try/14_auth_methods_tryouts.rb
167
+ - try/15_file_tryouts.rb
168
+ - try/20_file_transfer_tryouts.rb
169
+ - try/25_template_upload.rb
170
+ - try/30_safemode_tryouts.rb
171
+ - try/35_basics_with_hop.rb
172
+ - try/70_rye_cli_tryouts.rb
173
+ - try/copying.rb
174
+ - try/keys.rb
175
+ - tst/10-key1
176
+ - tst/10-key1.pub
177
+ - tst/10-key2
178
+ - tst/10-key2.pub
179
+ - tst/10_keys_test.rb
180
+ - tst/50_rset_test.rb
181
+ - tst/60-file.mp3
182
+ - tst/60_rbox_transfer_test.rb
183
+ - tst/65_rbox_file_append_test.rb
184
+ - tst/70_rbox_env_test.rb
185
+ - tst/dsl_example.rb
186
+ - tst/rye.rb
187
+ - tst/shell.rb
188
+ - tst/shell2.rb
189
+ - tst/shell3.rb
190
+ - tst/test_hop.rb
191
+ homepage: https://github.com/delano/rye
119
192
  licenses: []
120
193
  post_install_message:
121
- rdoc_options:
122
- - --line-numbers
123
- - --title
124
- - ! 'Rye: Safely run SSH commands on a bunch of machines at the same time (from Ruby).'
125
- - --main
126
- - README.rdoc
194
+ rdoc_options: []
127
195
  require_paths:
128
196
  - lib
129
197
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -132,23 +200,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
200
  - - ! '>='
133
201
  - !ruby/object:Gem::Version
134
202
  version: '0'
135
- segments:
136
- - 0
137
- hash: -1540559610647947478
138
203
  required_rubygems_version: !ruby/object:Gem::Requirement
139
204
  none: false
140
205
  requirements:
141
206
  - - ! '>='
142
207
  - !ruby/object:Gem::Version
143
208
  version: '0'
144
- segments:
145
- - 0
146
- hash: -1540559610647947478
147
209
  requirements: []
148
210
  rubyforge_project: rye
149
- rubygems_version: 1.8.22
211
+ rubygems_version: 1.8.25
150
212
  signing_key:
151
- specification_version: 2
152
- summary: ! 'Rye: Safely run SSH commands on a bunch of machines at the same time (from
153
- Ruby).'
213
+ specification_version: 3
214
+ summary: Run SSH commands on a bunch of machines at the same time (from Ruby).
154
215
  test_files: []
Binary file
data/bin/try DELETED
@@ -1,246 +0,0 @@
1
- #!/usr/bin/ruby
2
- # encoding: UTF-8
3
-
4
- # Rye -- A working example
5
- #
6
- # If your reading this via the rdocs you won't be able to see the code
7
- # See: http://github.com/delano/rye/blob/master/bin/try
8
- #
9
- # Usage: bin/try
10
- #
11
-
12
- RYE_HOME = File.join(File.dirname(__FILE__), '..')
13
- $:.unshift File.join(RYE_HOME, 'lib')
14
- %w{net-ssh sysinfo storable drydock}.each { |dir| $:.unshift File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
15
-
16
- require 'stringio'
17
- require 'yaml'
18
- require 'rye'
19
-
20
-
21
- puts %Q(
22
- # ------------------------------------------------------------------
23
- # EXAMPLE 1 -- Basic Usage
24
- #)
25
-
26
- rbox = Rye::Box.new('localhost')
27
-
28
- # Commands are run as methods on the Rye::Box object
29
- puts rbox.uptime # => 11:02 up 16:01, 3 users
30
-
31
- # The response value for all commands is a Rye::Rap object. The rap is a
32
- # subclass of Array so you can treat it as an Array, but it can also act
33
- # like a String if there's only one element.
34
- p rbox.ls(:a, '/') # => ['.', '..', 'bin', 'etc', ...]
35
-
36
- # You can change directories
37
- puts rbox.pwd # => /home/rye
38
- puts rbox['/usr/bin'].pwd # => /usr/bin
39
- puts rbox.pwd # => /usr/bin
40
-
41
- # You can specify environment variables
42
- rbox.setenv(:RYE, "Forty Creek")
43
- rbox.env # => ['HOME=/home/rye', 'RYE=Forty Creek', ...]
44
-
45
- # The commands method returns an Array of available commands:
46
- puts rbox.commands.join(', ') # => pwd, touch, echo, wc, ...
47
-
48
- # When you're done you can disconnect explicitly.
49
- # (Although Rye does this automatically at exit.)
50
- rbox.disconnect
51
-
52
-
53
- puts %Q(
54
- # ------------------------------------------------------------------
55
- # EXAMPLE 2 -- Disabling Safe-Mode
56
- #)
57
-
58
- rbox_safe = Rye::Box.new('localhost')
59
- rbox_wild = Rye::Box.new('localhost', :safe => false)
60
-
61
- # Safe-mode is enabled by default. In safe-mode, all command
62
- # arguments are thoroughly escaped. This prevents access to
63
- # environment variables and file globs (among other things).
64
- p rbox_safe.echo('$HOME') # => "$HOME"
65
- p rbox_safe['/etc'].ls('host*') rescue Rye::Err # Doesn't exist
66
- p rbox_safe.ls('-l | wc -l') rescue Rye::Err # => '|' is not a valid ls arg
67
-
68
- # Here's the same commands with safe-mode disabled:
69
- p rbox_wild.echo('$HOME') # => "/home/rye"
70
- p rbox_wild['/etc'].ls('host*') # => ["hostconfig", "hosts"]
71
- p rbox_wild.ls('-l | wc -l') # => 110
72
- p rbox_wild.echo('$HOME > /tmp/rye-home') # =>
73
- p rbox_wild.cat('/tmp/rye-home') # => "/home/rye"
74
-
75
-
76
-
77
- puts %Q(
78
- # ------------------------------------------------------------------
79
- # EXAMPLE 3 -- Custom Commands
80
- #)
81
-
82
- rbox = Rye::Box.new('localhost')
83
- rbox.add_keys('/private/key/path') # Specify additional private keys
84
-
85
- # There's currently no rye900 command
86
- p rbox.command?('rye9000') # => false
87
-
88
- # But we can add our own commands to the Rye::Cmd class. They
89
- # automatically become available to all Rye::Box objects.
90
- module Rye::Cmd
91
- def rye9000(*args)
92
- run_command("ls", args)
93
- end
94
- def somescript(*args)
95
- run_command("/path/to/my/script", args)
96
- end
97
- end
98
-
99
- # We can now run rye9000 (with arguments)
100
- p rbox.rye9000('-a') # => [".", "..", ".bashrc", ...]
101
- p rbox.command?('rye9000') # => true
102
-
103
-
104
- puts %Q(
105
- # ------------------------------------------------------------------
106
- # EXAMPLE 4 -- Accessing Multiple Machines
107
- #)
108
-
109
- rset = Rye::Set.new('default', :parallel => true)
110
- rbox = Rye::Box.new
111
- p rbox
112
-
113
- rset.add_keys('/private/key/path') # For passwordless logins
114
- rset.add_boxes(rbox, '127.0.0.1') # Add boxes as hostnames or objects
115
-
116
- # Calling methods on Rye::Set objects is very similar to calling them on
117
- # Rye::Box objects. In fact, it's identical:
118
- p rset.uptime # => [[14:19:02 up 32 days, 19:35 ...], [14:19:02 up 30 days, 01:35]]
119
- p rset['/usr'].ls # => [['bin', 'etc', ...], ['bin', 'etc', ...]]
120
-
121
- # Like Rye::Box, the response value is a Rye::Rap object containing the
122
- # responses from each box. Each response is itself a Rye::Rap object.
123
- unames = rset.uname
124
- p unames # => [["Darwin"], ["Darwin"]]
125
- puts unames.class # => Rye::Rap
126
-
127
- # The Rye::Rap object also keeps a reference to the object that called the
128
- # command. In this case, it will keep a reference to Rye::Set:
129
- puts unames.set.class # => Rye::Set
130
- puts unames.set == rset # => true
131
- puts unames.size # => 2
132
- puts unames.first # => Darwin
133
- puts unames.first.class # => Rye::Rap
134
- puts unames.first.box.class # => Rye::Box
135
- puts unames.first.box == rbox # => true
136
-
137
- # Envrionment variables can be set the same way as with Rye::Box
138
- rset.setenv(:RYE, "Forty Creek")
139
- p rset.env.first.select { |env| env =~ /RYE/ } # => ["RYE=Forty Creek"]
140
-
141
-
142
- puts %Q(
143
- # ------------------------------------------------------------------
144
- # EXAMPLE 5 -- ERROR HANDLING
145
- #)
146
-
147
- rbox = Rye::Box.new('localhost', :safe => false) # Note: safe mode is off
148
-
149
- # Rye follows the standard convention of taking exception to a non-zero
150
- # exit code by raising a Rye::Err. In this case, rye9000.test
151
- # is not found by the ls command.
152
- begin
153
- rbox.ls('rye.test')
154
- rescue Rye::Err => ex
155
- puts ex.exit_status # => 1
156
- puts ex.stderr # => ls: rye.test: No such file or directory
157
- end
158
-
159
- # The Rye:Rap response objects also give you the STDOUT and STDERR
160
- # content separately. Here we redirect STDOUT to STDERR, so this
161
- # will return nothing:
162
- puts rbox.uname('-a 1>&2').stdout # =>
163
-
164
- # It all went to STDERR:
165
- puts rbox.uname('-a 1>&2').stderr # => Darwin ryehost 9.6.0 ...
166
-
167
- # There were no actual errors so the exit code should be 0.
168
- puts rbox.uname('-a 1>&2').exit_status # => 0
169
-
170
-
171
- puts %Q(
172
- # ------------------------------------------------------------------
173
- # EXAMPLE 6 -- FILE TRANSFERS
174
- #)
175
-
176
- dir_upload = "#{Rye.sysinfo.tmpdir}rye-upload"
177
- dir_download = "#{Rye.sysinfo.tmpdir}rye-download"
178
-
179
- rbox = Rye::Box.new("localhost", :info => STDOUT)
180
-
181
- # Rye ships without an rm method (for safety!). Here
182
- # we add the rm method only to this instance of rbox.
183
- def rbox.rm(*args); __allow('rm', args); end
184
-
185
- rbox.rm(:r, :f, dir_upload) # Silently delete test dirs
186
- rbox.rm(:r, :f, dir_download)
187
-
188
- rbox.file_upload("#{RYE_HOME}/README.rdoc",
189
- "#{RYE_HOME}/LICENSE.txt", dir_upload)
190
-
191
- applejack = StringIO.new("Some in-memory content")
192
- rbox.file_upload(applejack, "#{dir_upload}/applejack.txt")
193
-
194
- p rbox.ls(dir_upload) # => [README.rdoc, LICENSE.txt, applejack.txt]
195
- p rbox.cat("#{dir_upload}/applejack.txt") # => "Some in-memory content"
196
-
197
- filecontent = StringIO.new
198
- rbox.file_download("#{dir_upload}/applejack.txt", filecontent)
199
- filecontent.rewind
200
- p filecontent.read
201
-
202
-
203
- puts %Q(
204
- # ------------------------------------------------------------------
205
- # EXAMPLE 7 -- FILE TRANSFERS w/ VARIABLE INTERPOLATION
206
- #)
207
-
208
- dir_upload = "#{Rye.sysinfo.tmpdir}rye-upload"
209
- dir_download = "#{Rye.sysinfo.tmpdir}rye-download"
210
-
211
- rbox = Rye::Box.new("localhost", :info => STDOUT)
212
-
213
- # Rye ships without an rm method (for safety!). Here
214
- # we add the rm method only to this instance of rbox.
215
- def rbox.rm(*args); __allow('rm', args); end
216
-
217
- rbox.rm(:r, :f, dir_upload) # Silently delete test dirs
218
- rbox.rm(:r, :f, dir_download)
219
-
220
- template = StringIO.new("Can we use templates? <%= 'Yes!' %>")
221
- rbox.mkdir dir_upload
222
-
223
- rbox.template_write("#{dir_upload}/template.txt", template)
224
-
225
- p rbox.ls(dir_upload) # => [template.txt]
226
- p rbox.cat("#{dir_upload}/template.txt") # => "Can we use templates? Yes!"
227
-
228
-
229
- puts %Q(
230
- # ------------------------------------------------------------------
231
- # EXAMPLE 8 -- LOCAL PROCESSES
232
- #)
233
-
234
- p Rye.shell :uptime
235
-
236
- p Rye.shell :ls, '*'
237
- p Rye.shell :ls, '-l $HOME'
238
- p Rye.shell :ls, :l, '$HOME > crazy.txt'
239
-
240
- Rye.shell :rm, 'crazy.txt'
241
-
242
- ret = Rye.shell :ls, 'nofile'
243
- p ret.exit_status # => 1
244
- p ret.stderr # => "sh: nofile: No such file or directory"
245
- p ret.class # => Rye::Rap
246
-