net-sftp 1.1.1 → 2.0.0

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.
Files changed (138) hide show
  1. data/CHANGELOG.rdoc +23 -0
  2. data/Manifest +55 -0
  3. data/README.rdoc +96 -0
  4. data/Rakefile +30 -0
  5. data/lib/net/sftp.rb +53 -38
  6. data/lib/net/sftp/constants.rb +187 -0
  7. data/lib/net/sftp/errors.rb +34 -20
  8. data/lib/net/sftp/operations/dir.rb +93 -0
  9. data/lib/net/sftp/operations/download.rb +364 -0
  10. data/lib/net/sftp/operations/file.rb +176 -0
  11. data/lib/net/sftp/operations/file_factory.rb +60 -0
  12. data/lib/net/sftp/operations/upload.rb +387 -0
  13. data/lib/net/sftp/packet.rb +21 -0
  14. data/lib/net/sftp/protocol.rb +32 -0
  15. data/lib/net/sftp/protocol/01/attributes.rb +265 -96
  16. data/lib/net/sftp/protocol/01/base.rb +268 -0
  17. data/lib/net/sftp/protocol/01/name.rb +43 -0
  18. data/lib/net/sftp/protocol/02/base.rb +31 -0
  19. data/lib/net/sftp/protocol/03/base.rb +35 -0
  20. data/lib/net/sftp/protocol/04/attributes.rb +120 -195
  21. data/lib/net/sftp/protocol/04/base.rb +94 -0
  22. data/lib/net/sftp/protocol/04/name.rb +67 -0
  23. data/lib/net/sftp/protocol/05/base.rb +66 -0
  24. data/lib/net/sftp/protocol/06/attributes.rb +107 -0
  25. data/lib/net/sftp/protocol/06/base.rb +63 -0
  26. data/lib/net/sftp/protocol/base.rb +50 -0
  27. data/lib/net/sftp/request.rb +91 -0
  28. data/lib/net/sftp/response.rb +76 -0
  29. data/lib/net/sftp/session.rb +914 -238
  30. data/lib/net/sftp/version.rb +14 -21
  31. data/net-sftp.gemspec +60 -0
  32. data/setup.rb +1331 -0
  33. data/test/common.rb +173 -0
  34. data/test/protocol/01/test_attributes.rb +97 -0
  35. data/test/protocol/01/test_base.rb +210 -0
  36. data/test/protocol/01/test_name.rb +27 -0
  37. data/test/protocol/02/test_base.rb +26 -0
  38. data/test/protocol/03/test_base.rb +27 -0
  39. data/test/protocol/04/test_attributes.rb +148 -0
  40. data/test/protocol/04/test_base.rb +74 -0
  41. data/test/protocol/04/test_name.rb +49 -0
  42. data/test/protocol/05/test_base.rb +62 -0
  43. data/test/protocol/06/test_attributes.rb +124 -0
  44. data/test/protocol/06/test_base.rb +51 -0
  45. data/test/protocol/test_base.rb +42 -0
  46. data/test/test_all.rb +3 -0
  47. data/test/test_dir.rb +47 -0
  48. data/test/test_download.rb +252 -0
  49. data/test/test_file.rb +159 -0
  50. data/test/test_file_factory.rb +48 -0
  51. data/test/test_packet.rb +9 -0
  52. data/test/test_protocol.rb +17 -0
  53. data/test/test_request.rb +71 -0
  54. data/test/test_response.rb +53 -0
  55. data/test/test_session.rb +741 -0
  56. data/test/test_upload.rb +219 -0
  57. metadata +59 -111
  58. data/doc/LICENSE-BSD +0 -27
  59. data/doc/LICENSE-GPL +0 -280
  60. data/doc/LICENSE-RUBY +0 -56
  61. data/doc/faq/faq.html +0 -298
  62. data/doc/faq/faq.rb +0 -154
  63. data/doc/faq/faq.yml +0 -183
  64. data/examples/asynchronous.rb +0 -57
  65. data/examples/get-put.rb +0 -45
  66. data/examples/sftp-open-uri.rb +0 -30
  67. data/examples/ssh-service.rb +0 -30
  68. data/examples/synchronous.rb +0 -131
  69. data/lib/net/sftp/operations/abstract.rb +0 -108
  70. data/lib/net/sftp/operations/close.rb +0 -31
  71. data/lib/net/sftp/operations/errors.rb +0 -76
  72. data/lib/net/sftp/operations/fsetstat.rb +0 -36
  73. data/lib/net/sftp/operations/fstat.rb +0 -32
  74. data/lib/net/sftp/operations/lstat.rb +0 -31
  75. data/lib/net/sftp/operations/mkdir.rb +0 -33
  76. data/lib/net/sftp/operations/open.rb +0 -32
  77. data/lib/net/sftp/operations/opendir.rb +0 -32
  78. data/lib/net/sftp/operations/read.rb +0 -88
  79. data/lib/net/sftp/operations/readdir.rb +0 -55
  80. data/lib/net/sftp/operations/realpath.rb +0 -37
  81. data/lib/net/sftp/operations/remove.rb +0 -31
  82. data/lib/net/sftp/operations/rename.rb +0 -32
  83. data/lib/net/sftp/operations/rmdir.rb +0 -31
  84. data/lib/net/sftp/operations/services.rb +0 -42
  85. data/lib/net/sftp/operations/setstat.rb +0 -33
  86. data/lib/net/sftp/operations/stat.rb +0 -31
  87. data/lib/net/sftp/operations/write.rb +0 -63
  88. data/lib/net/sftp/protocol/01/impl.rb +0 -251
  89. data/lib/net/sftp/protocol/01/packet-assistant.rb +0 -82
  90. data/lib/net/sftp/protocol/01/services.rb +0 -47
  91. data/lib/net/sftp/protocol/02/impl.rb +0 -39
  92. data/lib/net/sftp/protocol/02/packet-assistant.rb +0 -32
  93. data/lib/net/sftp/protocol/02/services.rb +0 -44
  94. data/lib/net/sftp/protocol/03/impl.rb +0 -42
  95. data/lib/net/sftp/protocol/03/packet-assistant.rb +0 -35
  96. data/lib/net/sftp/protocol/03/services.rb +0 -44
  97. data/lib/net/sftp/protocol/04/impl.rb +0 -86
  98. data/lib/net/sftp/protocol/04/packet-assistant.rb +0 -45
  99. data/lib/net/sftp/protocol/04/services.rb +0 -44
  100. data/lib/net/sftp/protocol/05/impl.rb +0 -90
  101. data/lib/net/sftp/protocol/05/packet-assistant.rb +0 -34
  102. data/lib/net/sftp/protocol/05/services.rb +0 -44
  103. data/lib/net/sftp/protocol/constants.rb +0 -60
  104. data/lib/net/sftp/protocol/driver.rb +0 -235
  105. data/lib/net/sftp/protocol/packet-assistant.rb +0 -84
  106. data/lib/net/sftp/protocol/services.rb +0 -55
  107. data/lib/uri/open-sftp.rb +0 -54
  108. data/lib/uri/sftp.rb +0 -42
  109. data/test/ALL-TESTS.rb +0 -23
  110. data/test/operations/tc_abstract.rb +0 -124
  111. data/test/operations/tc_close.rb +0 -40
  112. data/test/operations/tc_fsetstat.rb +0 -48
  113. data/test/operations/tc_fstat.rb +0 -40
  114. data/test/operations/tc_lstat.rb +0 -40
  115. data/test/operations/tc_mkdir.rb +0 -48
  116. data/test/operations/tc_open.rb +0 -42
  117. data/test/operations/tc_opendir.rb +0 -40
  118. data/test/operations/tc_read.rb +0 -103
  119. data/test/operations/tc_readdir.rb +0 -88
  120. data/test/operations/tc_realpath.rb +0 -54
  121. data/test/operations/tc_remove.rb +0 -40
  122. data/test/operations/tc_rmdir.rb +0 -40
  123. data/test/operations/tc_setstat.rb +0 -48
  124. data/test/operations/tc_stat.rb +0 -40
  125. data/test/operations/tc_write.rb +0 -91
  126. data/test/protocol/01/tc_attributes.rb +0 -138
  127. data/test/protocol/01/tc_impl.rb +0 -294
  128. data/test/protocol/01/tc_packet_assistant.rb +0 -81
  129. data/test/protocol/02/tc_impl.rb +0 -41
  130. data/test/protocol/02/tc_packet_assistant.rb +0 -31
  131. data/test/protocol/03/tc_impl.rb +0 -48
  132. data/test/protocol/03/tc_packet_assistant.rb +0 -34
  133. data/test/protocol/04/tc_attributes.rb +0 -174
  134. data/test/protocol/04/tc_impl.rb +0 -91
  135. data/test/protocol/04/tc_packet_assistant.rb +0 -38
  136. data/test/protocol/05/tc_impl.rb +0 -61
  137. data/test/protocol/05/tc_packet_assistant.rb +0 -32
  138. data/test/protocol/tc_driver.rb +0 -219
data/doc/faq/faq.rb DELETED
@@ -1,154 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2005, Jamis Buck (jamis@jamisbuck.org)
4
- # All rights reserved.
5
- #
6
- # Redistribution and use in source and binary forms, with or without
7
- # modification, are permitted provided that the following conditions are met:
8
- #
9
- # * Redistributions of source code must retain the above copyright notice,
10
- # this list of conditions and the following disclaimer.
11
- #
12
- # * Redistributions in binary form must reproduce the above copyright
13
- # notice, this list of conditions and the following disclaimer in the
14
- # documentation and/or other materials provided with the distribution.
15
- #
16
- # * The names of its contributors may not be used to endorse or promote
17
- # products derived from this software without specific prior written
18
- # permission.
19
- #
20
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24
- # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- # =============================================================================
31
- #++
32
-
33
- require 'yaml'
34
- require 'redcloth'
35
-
36
- def process_faq_list( faqs )
37
- puts "<ul>"
38
- faqs.each do |faq|
39
- process_faq_list_item faq
40
- end
41
- puts "</ul>"
42
- end
43
-
44
- def process_faq_list_item( faq )
45
- question = faq.keys.first
46
- answer = faq.values.first
47
-
48
- print "<li>"
49
-
50
- question_text = RedCloth.new(question).to_html.gsub( %r{</?p>},"" )
51
- if answer.is_a?( Array )
52
- puts question_text
53
- process_faq_list answer
54
- else
55
- print "<a href='##{question.object_id}'>#{question_text}</a>"
56
- end
57
-
58
- puts "</li>"
59
- end
60
-
61
- def process_faq_descriptions( faqs, path=nil )
62
- faqs.each do |faq|
63
- process_faq_description faq, path
64
- end
65
- end
66
-
67
- def process_faq_description( faq, path )
68
- question = faq.keys.first
69
- path = ( path ? path + " " : "" ) + question
70
- answer = faq.values.first
71
-
72
- if answer.is_a?( Array )
73
- process_faq_descriptions( answer, path )
74
- else
75
- title = RedCloth.new( path ).to_html.gsub( %r{</?p>}, "" )
76
- answer = RedCloth.new( answer || "" )
77
-
78
- puts "<a name='#{question.object_id}'></a>"
79
- puts "<div class='faq-title'>#{title}</div>"
80
- puts "<div class='faq-answer'>#{answer.to_html}</div>"
81
- end
82
- end
83
-
84
- faqs = YAML.load( File.read( "faq.yml" ) )
85
-
86
- puts <<-EOF
87
- <html>
88
- <head>
89
- <title>Net::SFTP FAQ</title>
90
- <style type="text/css">
91
- a, a:visited, a:active {
92
- color: #00F;
93
- text-decoration: none;
94
- }
95
-
96
- a:hover {
97
- text-decoration: underline;
98
- }
99
-
100
- .faq-list {
101
- color: #000;
102
- font-family: vera-sans, verdana, arial, sans-serif;
103
- }
104
-
105
- .faq-title {
106
- background: #007;
107
- color: #FFF;
108
- font-family: vera-sans, verdana, arial, sans-serif;
109
- padding-left: 1em;
110
- padding-top: 0.5em;
111
- padding-bottom: 0.5em;
112
- font-weight: bold;
113
- font-size: large;
114
- border: 1px solid #000;
115
- }
116
-
117
- .faq-answer {
118
- margin-left: 1em;
119
- color: #000;
120
- font-family: vera-sans, verdana, arial, sans-serif;
121
- }
122
-
123
- .faq-answer pre {
124
- margin-left: 1em;
125
- color: #000;
126
- background: #FFE;
127
- font-size: normal;
128
- border: 1px dotted #CCC;
129
- padding: 1em;
130
- }
131
-
132
- h1 {
133
- background: #005;
134
- color: #FFF;
135
- font-family: vera-sans, verdana, arial, sans-serif;
136
- padding-left: 1em;
137
- padding-top: 1em;
138
- padding-bottom: 1em;
139
- font-weight: bold;
140
- font-size: x-large;
141
- border: 1px solid #00F;
142
- }
143
- </style>
144
- </head>
145
- <body>
146
- <h1>Net::SFTP FAQ</h1>
147
- <div class="faq-list">
148
- EOF
149
-
150
- process_faq_list( faqs )
151
- puts "</div>"
152
- process_faq_descriptions( faqs )
153
-
154
- puts "</body></html>"
data/doc/faq/faq.yml DELETED
@@ -1,183 +0,0 @@
1
- ---
2
- - "What is Net::SFTP?": |
3
- Net::SFTP is a pure-Ruby implementation of the SFTP protocol. That's
4
- "SFTP" as in "Secure File Transfer Protocol", as defined as an adjuct to the
5
- SSH specification. _Not_ "SFTP" as in "Secure FTP" (a _completely_ different
6
- beast). Nor is it an implementation of the "Simple File Transfer Protocol"
7
- (which is in no way secure).
8
-
9
- - "How do I...":
10
- - "...connect to an SFTP server?":
11
- - "I'd like to connect without first getting a Net::SSH connection...": |
12
- Something like this:
13
-
14
- <code><pre>
15
- require 'net/sftp'
16
-
17
- Net::SFTP.start(host, user, password) do |sftp|
18
- ...
19
- end
20
- </pre></code>
21
-
22
- @Net::SFTP.start@ accepts the same parameters as @Net::SSH.start@,
23
- so I'll direct you to that documentation for all the particulars.
24
-
25
- - "I already have an open Net::SSH connection...": |
26
- You can piggy-back an SFTP connection on an existing Net::SSH
27
- connection, which can be useful if you've already got an SSH
28
- connection that you're using for port forwarding or whatever.
29
-
30
- <code><pre>
31
- require 'net/ssh'
32
- require 'net/sftp'
33
-
34
- Net::SSH.start(host, user, password) do |ssh|
35
- ...
36
- ssh.sftp.connect do |sftp|
37
- ...
38
- end
39
- ...
40
- end
41
- </pre></code>
42
-
43
- - "...upload data?":
44
- - "I want to upload an entire file on disk...": |
45
- Assuming you already have an SFTP connection:
46
-
47
- <code><pre>
48
- sftp.put_file "/path/to/local.file", "/path/to/remote.file"
49
- </pre></code>
50
-
51
- - "I want to upload bytes from a string or other object...": |
52
- Assuming you already have an SFTP connection, and your data is stored
53
- in a string named @data@:
54
-
55
- <code><pre>
56
- sftp.open_handle("/path/to/remote.file", "w") do |handle|
57
- result = sftp.write(handle, data)
58
- puts result.code # the result of the operation
59
- end
60
- </pre></code>
61
-
62
- If (for whatever reason) you'd rather not use blocks, you can do
63
- without, but be sure to call @close_handle@ when you're done:
64
-
65
- <code><pre>
66
- handle = sftp.open_handle("/path/to/remote.file", "w")
67
- result = sftp.write(handle, data)
68
- puts result.code # the result of the operation
69
- sftp.close_handle(handle)
70
- </pre></code>
71
-
72
- - "...download data?":
73
- - "I want to download directly to a local file...": |
74
- Assuming you already have an SFTP connection:
75
-
76
- <code><pre>
77
- sftp.get_file "/path/to/remote.file", "/path/to/local.file"
78
- </pre></code>
79
-
80
- - "I want to download to a string in memory...": |
81
- Assuming you already have an SFTP connection:
82
-
83
- <code><pre>
84
- data = nil
85
- sftp.open_handle("/path/to/remote.file") do |handle|
86
- data = sftp.read(handle)
87
- end
88
- </pre></code>
89
-
90
- - "I want to be notified of the progress of the download...": |
91
- You can specify both a "chunk size" and a "progress callback". The
92
- callback will be invoked for every "chunk size" bytes that are
93
- received:
94
-
95
- <code><pre>
96
- sftp.open_handle("/path/to/remote.file") do |handle|
97
- begin
98
- STDOUT.sync = true
99
- data = sftp.read(handle, :chunk_size => 4096,
100
- :progress_callback => lambda { |data| print "." })
101
- puts
102
- ensure
103
- STDOUT.sync = false
104
- end
105
- end
106
- </pre></code>
107
-
108
- - "...manage file permissions?":
109
- - "I want to query a file's permissions...": |
110
- File permissions are one of the @stat@ attributes of files and
111
- directories:
112
-
113
- <code><pre>
114
- p sftp.stat("/path/to/remote.file").permissions
115
- </pre></code>
116
-
117
- - "I want to change a file's permissions...": |
118
- Just use @setstat@ to change the permissions of an existing file:
119
-
120
- <code><pre>
121
- sftp.setstat("/path/to/remote.file", :permissions => 0644)
122
- </pre></code>
123
-
124
- - "I already have an open handle for the remote file...": |
125
- If you have a handle for the remote file, you can use @fstat@ and
126
- @fsetstat@ to query and set the permissions:
127
-
128
- <code><pre>
129
- sftp.open_handle("/path/to/remote.file") do |handle|
130
- permissions = sftp.fstat(handle)
131
- sftp.fsetstat(handle, :permissions => permissions | 0444)
132
- end
133
- </pre></code>
134
-
135
- - "...manage directories?":
136
- - "I want to query the contents of a directory...": |
137
- You query the contents of a directory by calling @opendir@ to obtain
138
- a handle to the directory, and then using @readdir@ on the handle to
139
- obtain a list of directory entries. Be sure to close the handle when
140
- you're done:
141
-
142
- <code><pre>
143
- handle = sftp.opendir("/usr/lib")
144
- items = sftp.readdir(handle)
145
- items.each do |item|
146
- puts item.filename
147
- puts item.longname
148
- p item.attributes # permissions, atime, etc.
149
- end
150
- sftp.close_handle(handle)
151
- </pre></code>
152
-
153
- - "I want to create a directory...": |
154
- Use @mkdir@:
155
-
156
- <code><pre>
157
- sftp.mkdir("/path/to/remote/dir", :permissions => 0500)
158
- </pre></code>
159
-
160
- - "I want to remove a directory...": |
161
- Use @rmdir@:
162
-
163
- <code><pre>
164
- sftp.rmdir("/path/to/remote/dir")
165
- </pre></code>
166
-
167
- - "...delete a file?": |
168
- Use @remove@:
169
-
170
- <code><pre>
171
- sftp.remove("/path/to/remote.file")
172
- </pre></code>
173
-
174
- - "...rename a file?": |
175
- Use @rename@:
176
-
177
- <code><pre>
178
- sftp.rename("/path/to/remote.file", "/path/to/new.file")
179
- </pre></code>
180
-
181
- It should be noted that @rename@ is only supported by version 2 or
182
- later of the SFTP protocol, so if you're using an older SFTP server you
183
- might not be able to use this operation.
@@ -1,57 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../lib"
18
- require 'net/sftp'
19
-
20
- Net::SFTP.start( 'localhost',
21
- :registry_options => { :logs => { :levels => { "sftp.*" => :debug } } }
22
- ) do |sftp|
23
- closed = 0
24
-
25
- size = sftp.stat( "temp/out" ).size
26
-
27
- # setting this to a higher value typically causes problems...looks like it
28
- # might be a problem with OpenSSH, but I'm not sure.
29
- parts = 5
30
-
31
- chunk_size = size / parts
32
- chunks = []
33
-
34
- # Set up 'parts' read operations, each one pulling from a different segment
35
- # of the file. Each of these will be run in parallel.
36
- parts.times do |part|
37
- sftp.open( "temp/out" ) do |s,h|
38
- puts "----------------------------------------------"
39
- puts "got handle ##{part+1} (#{h.inspect})"
40
- sftp.read( h, chunk_size*part, chunk_size ) do |s,data|
41
- puts "----------------------------------------------"
42
- puts "got data ##{part+1} (#{data.length} bytes)"
43
- chunks[part] = data
44
- sftp.close_handle( h ) do
45
- closed += 1
46
- sftp.close_channel if closed == parts
47
- end
48
- end
49
- end
50
- end
51
-
52
- sftp.loop
53
-
54
- puts "----------------------------------------------"
55
- data = chunks.join
56
- puts "done! (#{data.length} bytes)"
57
- end
data/examples/get-put.rb DELETED
@@ -1,45 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../lib"
18
- require 'net/sftp'
19
-
20
- Net::SFTP.start( 'localhost',
21
- :registry_options => { :logs => { :levels => { "sftp.*" => :debug } } }
22
- ) do |sftp|
23
- File.open( "test.data", "w" ) { |f| f.write "012345789"*10000 }
24
-
25
- puts "putting local file to remote location..."
26
- sftp.put_file "test.data", "temp/blah.data"
27
-
28
- puts "getting remote file to local location..."
29
- sftp.get_file "temp/blah.data", "new.data"
30
-
31
- sftp.remove "temp/blah.data"
32
-
33
- if !File.exist? "new.data"
34
- warn "----\n" +
35
- "something went wrong---'new.data' was apparently not created..." +
36
- "----\n"
37
- else
38
- File.delete "new.data"
39
- end
40
-
41
- File.delete "test.data"
42
-
43
- puts "----------------------------------------------"
44
- puts "done!"
45
- end
@@ -1,30 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../lib"
18
- require 'uri/open-sftp'
19
-
20
- uri = URI.parse( "sftp://localhost" +
21
- "/home/jgb3/temp/out" +
22
- "?encryption=blowfish-cbc&compression=zlib" )
23
-
24
- data = uri.open.read
25
- p data.length
26
-
27
- stream = uri.open( :chunk_size=>128,
28
- :progress_proc => proc { |d| print "."; $stdout.flush } )
29
- puts
30
- p stream.read.length