net-sftp 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,31 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # The implementation of the +lstat+ operation.
22
- class Lstat < Abstract
23
-
24
- # Request attributes for the file/directory at the given path.
25
- def perform( path )
26
- @driver.lstat( nil, path )
27
- end
28
-
29
- end
30
-
31
- end ; end ; end
@@ -1,33 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # The implementation of the +mkdir+ operation.
22
- class Mkdir < Abstract
23
-
24
- # Attempt to create the directory at the given path, giving it the
25
- # attributes specified by the hash.
26
- def perform( path, hash )
27
- attrs = @driver.attr_factory.from_hash( hash )
28
- @driver.mkdir( nil, path, attrs )
29
- end
30
-
31
- end
32
-
33
- end ; end ; end
@@ -1,32 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +open+ operation, for obtaining a handle to an open file
22
- # on the server.
23
- class Open < Abstract
24
-
25
- # Performs the operation.
26
- def perform( path, flags=IO::RDONLY, mode=0660 )
27
- @driver.open( nil, path, flags, mode )
28
- end
29
-
30
- end
31
-
32
- end ; end ; end
@@ -1,32 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +opendir+ operation, for obtaining a handle to an open
22
- # directory on the server.
23
- class Opendir < Abstract
24
-
25
- # Performs the operation.
26
- def perform( path )
27
- @driver.opendir( nil, path )
28
- end
29
-
30
- end
31
-
32
- end ; end ; end
@@ -1,88 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +read+ operation, which reads data from an open file handle.
22
- # This also implements the common case of reading to the end of the file. In
23
- # that case, the callback is guaranteed to receive the contents of the entire
24
- # file in one chunk.
25
- class Read < Abstract
26
-
27
- # The default maximum amount of data to read at once when reading an entire
28
- # file.
29
- DEFAULT_CHUNK_SIZE = 64 * 1024
30
-
31
- # Perform the operation. If length is less than 0 (the default), then the
32
- # entire file (from the given offset) will be read and returned in "one
33
- # fell swoop". Otherwise, the given length of data will be requested.
34
- def perform( handle, options={} )
35
- @length = options[:length] || -1
36
- @handle = handle
37
- @offset = options[:offset] || 0
38
- @chunk_size = options[:chunk_size] || DEFAULT_CHUNK_SIZE
39
- @progress_callback = options[:progress_callback]
40
- @data = ""
41
-
42
- real_length = ( @length >= 0 && @length < @chunk_size ?
43
- @length : @chunk_size )
44
- @driver.read( nil, @handle, @offset, real_length )
45
- end
46
-
47
- # Invoked when a data packet is received from the server. If the original
48
- # request was for an entire file, this will send another read request,
49
- # offset to the end of the data that has been read so far. Otherwise, the
50
- # callback will be invoked directly.
51
- def do_data( data )
52
- @log.debug "[#{@id}] got #{data.length} bytes" if @log.debug?
53
-
54
- @data << data
55
- @progress_callback[@data] if @progress_callback
56
-
57
- if @length < 0 || @data.length < @length
58
- if @length < 0
59
- length = @chunk_size
60
- else
61
- length = @length - @data.length
62
- length = length > @chunk_size ? @chunk_size : length
63
- end
64
-
65
- @log.debug "[#{@id}] requesting #{length} more bytes" if @log.debug?
66
- @driver.read @id, @handle, @offset + @data.length, length
67
- @session.register( @id, self )
68
- else
69
- @callback[ OK, @data ]
70
- end
71
- end
72
-
73
- # Invoked when a status code is received from the server. If the code is
74
- # FX_EOF, then no data could be read because the end of the file was
75
- # reached. In this case, the callback is invoked with the data that has been
76
- # read so far. Other status codes are handled by the superclass.
77
- def do_status( code, message, language )
78
- if code == FX_EOF
79
- @log.debug "[#{@id}] got EOF" if @log.debug?
80
- @callback[ OK, @data ]
81
- else
82
- super
83
- end
84
- end
85
-
86
- end
87
-
88
- end ; end ; end
@@ -1,55 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +readdir+ operation. This will handle the continuous calls
22
- # to +readdir+ until the entire contents of the directory have been read,
23
- # returning them in a single array.
24
- class Readdir < Abstract
25
-
26
- # Performs the operation.
27
- def perform( handle )
28
- @items = []
29
- @handle = handle
30
- @driver.readdir nil, @handle
31
- end
32
-
33
- # Invoked when the server returns a list of "names". Requests +readdir+
34
- # again, automatically.
35
- def do_name( items )
36
- @log.debug "[#{@id}] got #{items.length} items" if @log.debug?
37
- @items.concat items
38
- @driver.readdir @id, @handle
39
- @session.register @id, self
40
- end
41
-
42
- # Invoked when a status code is received from the server. If the code is
43
- # FX_OK or FX_EOF then there is nothing left to read and the callback is
44
- # invoked. Other status codes are handled by the superclass.
45
- def do_status( code, message, language )
46
- if code == FX_OK || code == FX_EOF
47
- @callback[ OK, @items ]
48
- else
49
- super
50
- end
51
- end
52
-
53
- end
54
-
55
- end ; end ; end
@@ -1,37 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +realpath+ operation.
22
- class Realpath < Abstract
23
-
24
- # Perform the operation.
25
- def perform( path )
26
- @driver.realpath( nil, path )
27
- end
28
-
29
- # A convenience--returns the first (and only) element of the array of items
30
- # that is returned, instead of returning the array itself.
31
- def do_name( items )
32
- @callback[ OK, items.first ]
33
- end
34
-
35
- end
36
-
37
- end ; end ; end
@@ -1,31 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +remove+ operation.
22
- class Remove < Abstract
23
-
24
- # Perform the operation.
25
- def perform( filename )
26
- @driver.remove( nil, filename )
27
- end
28
-
29
- end
30
-
31
- end ; end ; end
@@ -1,32 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +rename+ operation.
22
- class Rename < Abstract
23
-
24
- # Perform the operation. The flags parameter is ignored under earlier
25
- # versions of the SFTP protocol (3 and under).
26
- def perform( filename, new_name, flags=0 )
27
- @driver.rename( nil, filename, new_name, flags )
28
- end
29
-
30
- end
31
-
32
- end ; end ; end
@@ -1,31 +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
- require 'net/sftp/operations/abstract'
18
-
19
- module Net ; module SFTP ; module Operations
20
-
21
- # Implements the +rmdir+ operation.
22
- class Rmdir < Abstract
23
-
24
- # Perform the operation.
25
- def perform( path )
26
- @driver.rmdir( nil, path )
27
- end
28
-
29
- end
30
-
31
- end ; end ; end
@@ -1,42 +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
- module Net ; module SFTP ; module Operations
18
-
19
- # Register all services that implement an SFTP operation.
20
- def register_services( container )
21
- container.namespace :operations
22
- container.operations.use :model => :prototype do |ns|
23
- [
24
- :open,
25
- [ :close_handle, :close ],
26
- :read, :write, :opendir, :readdir, :remove,
27
- :stat, :lstat, :fstat, :setstat, :fsetstat,
28
- :mkdir, :rmdir, :realpath, :rename
29
- ].each do |op|
30
- array = op.is_a?( Array )
31
- ns.register( array ? op.first : op ) do |c,p|
32
- require "net/sftp/operations/#{array ? op.last : op}"
33
- klass_name = ( array ? op.last : op ).to_s
34
- klass = const_get( klass_name[0,1].upcase + klass_name[1..-1] )
35
- klass.new c[:log_for, p], c[:session], c[:protocol][:driver]
36
- end
37
- end
38
- end
39
- end
40
- module_function :register_services
41
-
42
- end ; end ; end