rye 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGES.txt +7 -0
  2. data/README.rdoc +2 -0
  3. data/bin/rye +1 -0
  4. data/lib/rye.rb +8 -6
  5. data/lib/rye/box.rb +1 -1
  6. data/rye.gemspec +8 -47
  7. metadata +29 -52
  8. data/bin/try +0 -201
  9. data/lib/sys.rb +0 -302
  10. data/try/copying.rb +0 -18
  11. data/try/keys.rb +0 -141
  12. data/tst/10-key1 +0 -27
  13. data/tst/10-key1.pub +0 -1
  14. data/tst/10-key2 +0 -30
  15. data/tst/10-key2.pub +0 -1
  16. data/tst/10_keys_test.rb +0 -88
  17. data/tst/50_rset_test.rb +0 -54
  18. data/tst/60-file.mp3 +0 -0
  19. data/tst/60_rbox_transfer_test.rb +0 -53
  20. data/tst/70_rbox_env_test.rb +0 -19
  21. data/vendor/highline-1.5.1/CHANGELOG +0 -222
  22. data/vendor/highline-1.5.1/INSTALL +0 -35
  23. data/vendor/highline-1.5.1/LICENSE +0 -7
  24. data/vendor/highline-1.5.1/README +0 -63
  25. data/vendor/highline-1.5.1/Rakefile +0 -82
  26. data/vendor/highline-1.5.1/TODO +0 -6
  27. data/vendor/highline-1.5.1/examples/ansi_colors.rb +0 -38
  28. data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +0 -18
  29. data/vendor/highline-1.5.1/examples/basic_usage.rb +0 -75
  30. data/vendor/highline-1.5.1/examples/color_scheme.rb +0 -32
  31. data/vendor/highline-1.5.1/examples/limit.rb +0 -12
  32. data/vendor/highline-1.5.1/examples/menus.rb +0 -65
  33. data/vendor/highline-1.5.1/examples/overwrite.rb +0 -19
  34. data/vendor/highline-1.5.1/examples/page_and_wrap.rb +0 -322
  35. data/vendor/highline-1.5.1/examples/password.rb +0 -7
  36. data/vendor/highline-1.5.1/examples/trapping_eof.rb +0 -22
  37. data/vendor/highline-1.5.1/examples/using_readline.rb +0 -17
  38. data/vendor/highline-1.5.1/lib/highline.rb +0 -758
  39. data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +0 -120
  40. data/vendor/highline-1.5.1/lib/highline/compatibility.rb +0 -17
  41. data/vendor/highline-1.5.1/lib/highline/import.rb +0 -43
  42. data/vendor/highline-1.5.1/lib/highline/menu.rb +0 -395
  43. data/vendor/highline-1.5.1/lib/highline/question.rb +0 -463
  44. data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +0 -193
  45. data/vendor/highline-1.5.1/setup.rb +0 -1360
  46. data/vendor/highline-1.5.1/test/tc_color_scheme.rb +0 -56
  47. data/vendor/highline-1.5.1/test/tc_highline.rb +0 -823
  48. data/vendor/highline-1.5.1/test/tc_import.rb +0 -54
  49. data/vendor/highline-1.5.1/test/tc_menu.rb +0 -429
  50. data/vendor/highline-1.5.1/test/ts_all.rb +0 -15
data/lib/sys.rb DELETED
@@ -1,302 +0,0 @@
1
- require 'socket'
2
-
3
- # SystemInfo
4
- #
5
- # A container for the platform specific system information.
6
- # Portions of this code were originally from Amazon's EC2 AMI tools,
7
- # specifically lib/platform.rb.
8
- class SystemInfo #:nodoc:all
9
- unless defined?(IMPLEMENTATIONS)
10
- VERSION = 5.freeze
11
- IMPLEMENTATIONS = [
12
-
13
- # These are for JRuby, System.getproperty('os.name').
14
- # For a list of all values, see: http://lopica.sourceforge.net/os.html
15
- [/mac\s*os\s*x/i, :unix, :osx ],
16
- [/sunos/i, :unix, :solaris ],
17
- [/windows\s*ce/i, :win32, :windows ],
18
- [/windows/i, :win32, :windows ],
19
- [/osx/i, :unix, :osx ],
20
-
21
- # TODO: implement other windows matches: # /djgpp|(cyg|ms|bcc)win|mingw/ (from mongrel)
22
-
23
- # These are for RUBY_PLATFORM and JRuby
24
- [/java/i, :java, :java ],
25
- [/darwin/i, :unix, :osx ],
26
- [/linux/i, :unix, :linux ],
27
- [/freebsd/i, :unix, :freebsd ],
28
- [/netbsd/i, :unix, :netbsd ],
29
- [/solaris/i, :unix, :solaris ],
30
- [/irix/i, :unix, :irix ],
31
- [/cygwin/i, :unix, :cygwin ],
32
- [/mswin/i, :win32, :windows ],
33
- [/mingw/i, :win32, :mingw ],
34
- [/bccwin/i, :win32, :bccwin ],
35
- [/wince/i, :win32, :wince ],
36
- [/vms/i, :vms, :vms ],
37
- [/os2/i, :os2, :os2 ],
38
- [nil, :unknown, :unknown ],
39
-
40
- ].freeze
41
-
42
- ARCHITECTURES = [
43
- [/(i\d86)/i, :i386 ],
44
- [/x86_64/i, :x86_64 ],
45
- [/x86/i, :i386 ], # JRuby
46
- [/ia64/i, :ia64 ],
47
- [/alpha/i, :alpha ],
48
- [/sparc/i, :sparc ],
49
- [/mips/i, :mips ],
50
- [/powerpc/i, :powerpc ],
51
- [/universal/i,:universal ],
52
- [nil, :unknown ],
53
- ].freeze
54
- end
55
-
56
-
57
- attr_reader :os
58
- attr_reader :implementation
59
- attr_reader :architecture
60
- attr_reader :hostname
61
- attr_reader :ipaddress
62
- attr_reader :uptime
63
-
64
-
65
- alias :impl :implementation
66
- alias :arch :architecture
67
-
68
-
69
- def initialize
70
- @os, @implementation, @architecture = guess
71
- @hostname, @ipaddress, @uptime = get_info
72
- end
73
-
74
- # guess
75
- #
76
- # This is called at require-time in stella.rb. It guesses
77
- # the current operating system, implementation, architecture.
78
- # Returns [os, impl, arch]
79
- def guess
80
- os = :unknown
81
- impl = :unknown
82
- arch = :unknown
83
- IMPLEMENTATIONS.each do |r, o, i|
84
- if r and RUBY_PLATFORM =~ r
85
- os, impl = [o, i]
86
- break
87
- end
88
- end
89
- ARCHITECTURES.each do |r, a|
90
- if r and RUBY_PLATFORM =~ r
91
- arch = a
92
- break
93
- end
94
- end
95
-
96
- #
97
- if os == :win32
98
- #require 'Win32API'
99
-
100
- # If we're running in java, we'll need to look elsewhere
101
- # for the implementation and architecture.
102
- # We'll replace IMPL and ARCH with what we find.
103
- elsif os == :java
104
- require 'java'
105
- include_class java.lang.System
106
-
107
- osname = System.getProperty("os.name")
108
- IMPLEMENTATIONS.each do |r, o, i|
109
- if r and osname =~ r
110
- impl = i
111
- break
112
- end
113
- end
114
-
115
- osarch = System.getProperty("os.arch")
116
- ARCHITECTURES.each do |r, a|
117
- if r and osarch =~ r
118
- arch = a
119
- break
120
- end
121
- end
122
-
123
- end
124
-
125
- [os, impl, arch]
126
- end
127
-
128
- # get_info
129
- #
130
- # Returns [hostname, ipaddr, uptime] for the local machine
131
- def get_info
132
- hostname = :unknown
133
- ipaddr = :unknown
134
- uptime = :unknown
135
-
136
- begin
137
- hostname = local_hostname
138
- ipaddr = local_ip_address
139
- uptime = local_uptime
140
- rescue => ex
141
- # Be silent!
142
- end
143
-
144
- [hostname, ipaddr, uptime]
145
- end
146
-
147
- # local_hostname
148
- #
149
- # Return the hostname for the local machine
150
- def local_hostname
151
- Socket.gethostname
152
- end
153
-
154
- # local_uptime
155
- #
156
- # Returns the local uptime in hours. Use Win32API in Windows,
157
- # 'sysctl -b kern.boottime' os osx, and 'who -b' on unix.
158
- # Based on Ruby Quiz solutions by: Matthias Reitinger
159
- # On Windows, see also: net statistics server
160
- def local_uptime
161
-
162
- # Each method must return uptime in seconds
163
- methods = {
164
-
165
- :win32_windows => lambda {
166
- # Win32API is required in self.guess
167
- getTickCount = Win32API.new("kernel32", "GetTickCount", nil, 'L')
168
- ((getTickCount.call()).to_f / 1000).to_f
169
- },
170
-
171
- # Ya, this is kinda wack. Ruby -> Java -> Kernel32. See:
172
- # http://www.oreillynet.com/ruby/blog/2008/01/jruby_meets_the_windows_api_1.html
173
- # http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx
174
- # Ruby 1.9.1: Win32API is now deprecated in favor of using the DL library.
175
- :java_windows => lambda {
176
- kernel32 = com.sun.jna.NativeLibrary.getInstance('kernel32')
177
- buf = java.nio.ByteBuffer.allocate(256)
178
- (kernel32.getFunction('GetTickCount').invokeInt([256, buf].to_java).to_f / 1000).to_f
179
- },
180
-
181
- :unix_osx => lambda {
182
- # This is faster than who and could work on BSD also.
183
- (Time.now.to_f - Time.at(`sysctl -b kern.boottime 2>/dev/null`.unpack('L').first).to_f).to_f
184
- },
185
- # This should work for most unix flavours.
186
- :unix => lambda {
187
- # who is sloooooow. Use File.read('/proc/uptime')
188
- (Time.now.to_f - Time.parse(`who -b 2>/dev/null`).to_f)
189
- }
190
- }
191
-
192
- hours = 0
193
-
194
- begin
195
- key = platform
196
- method = (methods.has_key? key) ? methods[key] : methods[:unix]
197
- hours = (method.call) / 3600 # seconds to hours
198
- rescue => ex
199
- end
200
- hours
201
- end
202
-
203
-
204
- #
205
- # Return the local IP address which receives external traffic
206
- # from: http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/
207
- # NOTE: This <em>does not</em> open a connection to the IP address.
208
- def local_ip_address
209
- # turn off reverse DNS resolution temporarily
210
- orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
211
- UDPSocket.open {|s| s.connect('75.101.137.7', 1); s.addr.last } # Solutious IP
212
- ensure
213
- Socket.do_not_reverse_lookup = orig
214
- end
215
-
216
- #
217
- # Returns the local IP address based on the hostname.
218
- # According to coderrr (see comments on blog link above), this implementation
219
- # doesn't guarantee that it will return the address for the interface external
220
- # traffic goes through. It's also possible the hostname isn't resolvable to the
221
- # local IP.
222
- def local_ip_address_alt
223
- ipaddr = :unknown
224
- begin
225
- saddr = Socket.getaddrinfo( Socket.gethostname, nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
226
- ipaddr = saddr.select{|type| type[0] == 'AF_INET' }[0][3]
227
- rescue => ex
228
- end
229
- ipaddr
230
- end
231
-
232
- # returns a symbol in the form: os_implementation. This is used throughout Stella
233
- # for platform specific support.
234
- def platform
235
- "#{@os}_#{@implementation}".to_sym
236
- end
237
-
238
- # Returns Ruby version as an array
239
- def ruby
240
- RUBY_VERSION.split('.').map { |v| v.to_i }
241
- end
242
-
243
- # Returns the environment PATH as an Array
244
- def paths
245
- if @os == :unix
246
- (ENV['PATH'] || '').split(':')
247
- elsif @os == :win32
248
- (ENV['PATH'] || '').split(';') # Not tested!
249
- elsif @os == :java
250
- delim = @impl == :windows ? ';' : ':'
251
- (ENV['PATH'] || '').split(delim)
252
- else
253
- raise "paths not implemented for: #{@os}"
254
- end
255
- end
256
-
257
- def user
258
- ENV['USER']
259
- end
260
-
261
- def home
262
- if @os == :unix
263
- File.expand_path(ENV['HOME'])
264
- elsif @os == :win32
265
- File.expand_path(ENV['USERPROFILE'])
266
- elsif @os == :java
267
- if @impl == :windows
268
- File.expand_path(ENV['USERPROFILE'])
269
- else
270
- File.expand_path(ENV['HOME'])
271
- end
272
- else
273
- raise "paths not implemented for: #{@os}"
274
- end
275
- end
276
-
277
- def tmpdir
278
- if @os == :unix
279
- (ENV['TMPDIR'] || '/tmp')
280
- elsif @os == :win32
281
- (ENV['TMPDIR'] || 'C:\\temp')
282
- elsif @os == :java
283
- default = @impl == :windows ? 'C:\\temp' : '/tmp'
284
- (ENV['TMPDIR'] || default)
285
- else
286
- raise "paths not implemented for: #{@os}"
287
- end
288
- end
289
-
290
- # Print friendly system information.
291
- def to_s
292
- sprintf("Hostname: %s#{$/}IP Address: %s#{$/}System: %s#{$/}Uptime: %.2f (hours)#{$/}Ruby: #{ruby.join('.')}",
293
- @hostname, @ipaddress, "#{@os}-#{@implementation}-#{@architecture}", @uptime)
294
- end
295
-
296
-
297
- end
298
-
299
-
300
- if $0 == __FILE__
301
- puts SystemInfo.new.to_yaml
302
- end
@@ -1,18 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # THIS IS A SCRAP FILE.
4
-
5
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
-
7
- require 'rye'
8
- boxA = Rye::Box.new('localhost', :user => "delano")
9
- boxB = Rye::Box.new('127.0.0.1', :user => 'delano', :safe => false, :debug => STDOUT)
10
- set = Rye::Set.new
11
- set.add_boxes(boxA, boxB)
12
-
13
- #p boxA['/tmp/ssh-test'].cat.stderr
14
-
15
- #boxB['/tmp/ssh-test'].copy_to boxA['/tmp'], boxA['/tmp']
16
-
17
-
18
- p boxA.ls(:a)
@@ -1,141 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # THIS IS A SCRAP FILE.
4
-
5
-
6
-
7
- __END__
8
- require 'openssl'
9
- key = OpenSSL::PKey::RSA.generate(1024)
10
- pub = key.public_key
11
- ca = OpenSSL::X509::Name.parse("/C=US/ST=Florida/L=Miami/O=Waitingf/OU=Poopstat/CN=waitingf.org/emailAddress=bkerley@brycekerley.net")
12
- cert = OpenSSL::X509::Certificate.new
13
- cert.version = 2
14
- cert.serial = 1
15
- cert.subject = ca
16
- cert.issuer = ca
17
- cert.public_key = pub
18
- cert.not_before = Time.now
19
- cert.not_after = Time.now + 3600
20
- File.open("private.pem", "w") { |f| f.write key.to_pem }
21
- File.open("cert.pem", "w") { |f| f.write cert.to_pem }
22
-
23
- require "openssl"
24
-
25
-
26
- pkey = OpenSSL::PKey::RSA.new(512)
27
- cert = OpenSSL::X509::Certificate.new
28
- cert.version = 1
29
- cert.subject = cert.issuer = OpenSSL::X509::Name.parse("/C=FOO")
30
- cert.public_key = pkey.public_key
31
- cert.not_before = Time.now
32
- cert.not_after = Time.now+3600*24*365
33
- cert.sign(pkey, OpenSSL::Digest::SHA1.new)
34
- p12 = OpenSSL::PKCS12.create("passwd", "FriendlyName", pkey, cert)
35
- #puts p12.to_der
36
-
37
- __END__
38
- # Tasks demonstrated:
39
- # Creating a public-private key pair
40
- # Saving individual keys to disk in PEM format
41
- # Reading individual keys from disk
42
- # Encyrpting with public key
43
- # Decrypting with private key
44
- # Checking whether a key has public | private key
45
-
46
- require 'openssl'
47
-
48
- # in a real rsa implementation, message would be the symmetric key
49
- # used to encrypt the real message data
50
- # which would be 'yourpass' in snippet http://www.bigbold.com/snippets/posts/show/576
51
- message = "This is some cool text."
52
- puts "\nOriginal Message: #{message}\n"
53
-
54
- puts "Using ruby-openssl to generate the public and private keys\n"
55
-
56
- # .generate creates an object containing both keys
57
- new_key = OpenSSL::PKey::RSA.generate( 1024 )
58
- puts "Does the generated key object have the public key? #{new_key.public?}\n"
59
- puts "Does the generated key object have the private key? #{new_key.private?}\n\n"
60
-
61
- # write the new keys as PEM's
62
- new_public = new_key.public_key
63
- puts "New public key pem:\n#{new_public}\n"
64
- puts "The new public key in human readable form:\n"
65
- puts new_public.to_text + "\n"
66
-
67
- output_public = File.new("./new_public.pem", "w")
68
- output_public.puts new_public
69
- output_public.close
70
-
71
- new_private = new_key.to_pem
72
- puts "new private key pem:\n#{new_private}\n"
73
-
74
- output_private = File.new("./new_private.pem", "w")
75
- output_private.puts new_private
76
- output_private.close
77
-
78
- puts "\nEncrypt/decrypt using previously saved pem files on disk...\n"
79
- # we encrypt with the public key
80
- # note: of course the public key PEM contains only the public key
81
- puts "Reading Public Key PEM...\n"
82
- public_key = OpenSSL::PKey::RSA.new(File.read("./new_public.pem"))
83
- puts "Does the public pem file have the public key? #{public_key.public?}\n"
84
- puts "Does the public pem file have the private key? #{public_key.private?}\n"
85
- puts "\nEncrypting with public key ...\n"
86
- cipher_text = public_key.public_encrypt( message )
87
- puts "cipher text:\n#{cipher_text}\n"
88
-
89
- # get the private key from pem file and decrypt
90
- # note the private key PEM contains both keys
91
- puts "\nReading Private Key PEM...\n"
92
- private_key = OpenSSL::PKey::RSA.new(File.read("./new_private.pem"))
93
- puts "Does the private pem file have the public key? #{private_key.public?}\n"
94
- puts "Does the private pem file have the private key? #{private_key.private?}\n"
95
- puts "\nDecrypting with private key ...\n"
96
- clear_text = private_key.private_decrypt( cipher_text )
97
- puts "\ndecoded text:\n#{clear_text}\n\n"
98
-
99
-
100
- __END__
101
-
102
- # outputs: -rw-r--r--
103
- def self.calc_mode pbit
104
- # permission bit
105
- mode = Array.new(10, '-')
106
- mt = pbit & 0170000
107
- # S_IFMT
108
- case mt
109
- # S_IFDIR
110
- when 00040000
111
- mode[0] = 'd'
112
- # S_IFBLK
113
- when 0060000
114
- mode[0] = 'b'
115
- # S_IFCHR
116
- when 0020000
117
- mode[0] = 'c'
118
- # S_IFLNK
119
- when 0120000
120
- mode[0] = 'l'
121
- # S_IFFIFO
122
- when 0010000
123
- mode[0] = 'p'
124
- # S_IFSOCK
125
- when 0140000
126
- mode[0] = 's'
127
- end
128
- u = pbit & 00700
129
- g = pbit & 00070
130
- o = pbit & 00007
131
- mode[1] = 'r' if u & 00400 != 0
132
- mode[2] = 'w' if u & 00200 != 0
133
- mode[3] = 'x' if u & 00100 != 0
134
- mode[4] = 'r' if g & 00040 != 0
135
- mode[5] = 'w' if g & 00020 != 0
136
- mode[6] = 'x' if g & 00010 != 0
137
- mode[7] = 'r' if o & 00004 != 0
138
- mode[8] = 'w' if o & 00002 != 0
139
- mode[9] = 'x' if o & 00001 != 0
140
- mode.join('')
141
- end