redcar 0.3.7.1 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/CHANGES +16 -0
  2. data/README.md +5 -0
  3. data/ROADMAP.md +7 -9
  4. data/Rakefile +55 -22
  5. data/lib/redcar.rb +12 -6
  6. data/lib/redcar/installer.rb +119 -44
  7. data/plugins/application/features/step_definitions/speedbar_steps.rb +62 -0
  8. data/plugins/application/features/step_definitions/tree_steps.rb +3 -3
  9. data/plugins/application/features/support/env.rb +2 -1
  10. data/plugins/application/lib/application/notebook.rb +53 -7
  11. data/plugins/application/lib/application/speedbar.rb +12 -0
  12. data/plugins/application/lib/application/tab.rb +16 -5
  13. data/plugins/application/lib/application/treebook.rb +21 -1
  14. data/plugins/application_swt/lib/application_swt.rb +12 -2
  15. data/plugins/application_swt/lib/application_swt/html_tab.rb +4 -0
  16. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -3
  17. data/plugins/application_swt/lib/application_swt/speedbar.rb +15 -27
  18. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +1 -0
  19. data/plugins/application_swt/lib/application_swt/tab.rb +1 -0
  20. data/plugins/application_swt/lib/application_swt/treebook.rb +36 -8
  21. data/plugins/application_swt/lib/application_swt/window.rb +24 -18
  22. data/plugins/auto_completer/lib/auto_completer.rb +5 -20
  23. data/plugins/core/lib/core.rb +7 -4
  24. data/plugins/core/lib/core/observable_struct.rb +2 -2
  25. data/plugins/declarations/lib/declarations.rb +3 -17
  26. data/plugins/document_search/features/search.feature +163 -0
  27. data/plugins/document_search/features/support/env.rb +4 -0
  28. data/plugins/document_search/lib/document_search.rb +121 -0
  29. data/plugins/document_search/plugin.rb +8 -0
  30. data/plugins/edit_view/features/line_delimiter.feature +7 -0
  31. data/plugins/edit_view/features/step_definitions/editing_steps.rb +49 -1
  32. data/plugins/edit_view/features/step_definitions/tab_steps.rb +10 -11
  33. data/plugins/edit_view/features/switch_tabs.feature +61 -10
  34. data/plugins/edit_view/lib/edit_view.rb +4 -0
  35. data/plugins/edit_view/lib/edit_view/document.rb +56 -0
  36. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  37. data/plugins/edit_view/lib/edit_view/edit_tab.rb +0 -8
  38. data/plugins/edit_view_swt/lib/edit_view_swt.rb +4 -0
  39. data/plugins/html_view/lib/html_controller.rb +19 -1
  40. data/plugins/html_view/lib/html_view.rb +28 -1
  41. data/plugins/html_view/lib/html_view/html_tab.rb +10 -1
  42. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +3 -1
  43. data/plugins/project/features/open_directory_tree.feature +3 -3
  44. data/plugins/project/lib/project.rb +4 -6
  45. data/plugins/project/lib/project/commands.rb +17 -0
  46. data/plugins/project/lib/project/dir_controller.rb +2 -1
  47. data/plugins/project/lib/project/dir_mirror.rb +8 -0
  48. data/plugins/project/lib/project/manager.rb +2 -0
  49. data/plugins/project/plugin.rb +2 -1
  50. data/plugins/project/vendor/net-sftp/Manifest +55 -0
  51. data/plugins/project/vendor/net-sftp/Rakefile +30 -0
  52. data/plugins/project/vendor/net-sftp/lib/net/sftp.rb +70 -0
  53. data/plugins/project/vendor/net-sftp/lib/net/sftp/constants.rb +187 -0
  54. data/plugins/project/vendor/net-sftp/lib/net/sftp/errors.rb +39 -0
  55. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/dir.rb +93 -0
  56. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/download.rb +364 -0
  57. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file.rb +176 -0
  58. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file_factory.rb +60 -0
  59. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/upload.rb +387 -0
  60. data/plugins/project/vendor/net-sftp/lib/net/sftp/packet.rb +21 -0
  61. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol.rb +32 -0
  62. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/attributes.rb +315 -0
  63. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/base.rb +268 -0
  64. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/name.rb +43 -0
  65. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/02/base.rb +31 -0
  66. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/03/base.rb +35 -0
  67. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/attributes.rb +152 -0
  68. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/base.rb +94 -0
  69. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/name.rb +67 -0
  70. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/05/base.rb +66 -0
  71. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/attributes.rb +107 -0
  72. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/base.rb +63 -0
  73. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/base.rb +50 -0
  74. data/plugins/project/vendor/net-sftp/lib/net/sftp/request.rb +91 -0
  75. data/plugins/project/vendor/net-sftp/lib/net/sftp/response.rb +76 -0
  76. data/plugins/project/vendor/net-sftp/lib/net/sftp/session.rb +951 -0
  77. data/plugins/project/vendor/net-sftp/lib/net/sftp/version.rb +18 -0
  78. data/plugins/project/vendor/net-sftp/setup.rb +1331 -0
  79. data/plugins/project/vendor/net-sftp/test/common.rb +171 -0
  80. data/plugins/project/vendor/net-sftp/test/protocol/01/test_attributes.rb +97 -0
  81. data/plugins/project/vendor/net-sftp/test/protocol/01/test_base.rb +210 -0
  82. data/plugins/project/vendor/net-sftp/test/protocol/01/test_name.rb +27 -0
  83. data/plugins/project/vendor/net-sftp/test/protocol/02/test_base.rb +26 -0
  84. data/plugins/project/vendor/net-sftp/test/protocol/03/test_base.rb +27 -0
  85. data/plugins/project/vendor/net-sftp/test/protocol/04/test_attributes.rb +148 -0
  86. data/plugins/project/vendor/net-sftp/test/protocol/04/test_base.rb +74 -0
  87. data/plugins/project/vendor/net-sftp/test/protocol/04/test_name.rb +53 -0
  88. data/plugins/project/vendor/net-sftp/test/protocol/05/test_base.rb +62 -0
  89. data/plugins/project/vendor/net-sftp/test/protocol/06/test_attributes.rb +124 -0
  90. data/plugins/project/vendor/net-sftp/test/protocol/06/test_base.rb +51 -0
  91. data/plugins/project/vendor/net-sftp/test/protocol/test_base.rb +42 -0
  92. data/plugins/project/vendor/net-sftp/test/test_all.rb +7 -0
  93. data/plugins/project/vendor/net-sftp/test/test_dir.rb +47 -0
  94. data/plugins/project/vendor/net-sftp/test/test_download.rb +252 -0
  95. data/plugins/project/vendor/net-sftp/test/test_file.rb +159 -0
  96. data/plugins/project/vendor/net-sftp/test/test_file_factory.rb +48 -0
  97. data/plugins/project/vendor/net-sftp/test/test_packet.rb +9 -0
  98. data/plugins/project/vendor/net-sftp/test/test_protocol.rb +17 -0
  99. data/plugins/project/vendor/net-sftp/test/test_request.rb +71 -0
  100. data/plugins/project/vendor/net-sftp/test/test_response.rb +53 -0
  101. data/plugins/project/vendor/net-sftp/test/test_session.rb +741 -0
  102. data/plugins/project/vendor/net-sftp/test/test_upload.rb +219 -0
  103. data/plugins/project/vendor/net-ssh/Manifest +110 -0
  104. data/plugins/project/vendor/net-ssh/Rakefile +85 -0
  105. data/plugins/project/vendor/net-ssh/Rudyfile +96 -0
  106. data/plugins/project/vendor/net-ssh/lib/net/ssh.rb +215 -0
  107. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/agent.rb +179 -0
  108. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  109. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  110. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  111. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  112. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  113. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  114. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  115. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  116. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  117. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffer.rb +340 -0
  118. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffered_io.rb +198 -0
  119. data/plugins/project/vendor/net-ssh/lib/net/ssh/config.rb +202 -0
  120. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/channel.rb +630 -0
  121. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  122. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/session.rb +597 -0
  123. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  124. data/plugins/project/vendor/net-ssh/lib/net/ssh/errors.rb +85 -0
  125. data/plugins/project/vendor/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  126. data/plugins/project/vendor/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  127. data/plugins/project/vendor/net-ssh/lib/net/ssh/loggable.rb +61 -0
  128. data/plugins/project/vendor/net-ssh/lib/net/ssh/packet.rb +102 -0
  129. data/plugins/project/vendor/net-ssh/lib/net/ssh/prompt.rb +93 -0
  130. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/command.rb +75 -0
  131. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  132. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  133. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  134. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks5.rb +142 -0
  135. data/plugins/project/vendor/net-ssh/lib/net/ssh/ruby_compat.rb +43 -0
  136. data/plugins/project/vendor/net-ssh/lib/net/ssh/service/forward.rb +288 -0
  137. data/plugins/project/vendor/net-ssh/lib/net/ssh/test.rb +89 -0
  138. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  139. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  140. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  141. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  142. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  143. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  144. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/script.rb +157 -0
  145. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/socket.rb +64 -0
  146. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  147. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/cipher_factory.rb +97 -0
  148. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  149. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  150. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +79 -0
  151. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  152. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  153. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  154. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  155. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  156. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  157. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  158. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  159. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  160. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  161. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/packet_stream.rb +235 -0
  162. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/server_version.rb +71 -0
  163. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  164. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/state.rb +206 -0
  165. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  166. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  167. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  168. data/plugins/project/vendor/net-ssh/lib/net/ssh/version.rb +62 -0
  169. data/plugins/project/vendor/net-ssh/net-ssh.gemspec +138 -0
  170. data/plugins/project/vendor/net-ssh/setup.rb +1585 -0
  171. data/plugins/project/vendor/net-ssh/support/arcfour_check.rb +20 -0
  172. data/plugins/project/vendor/net-ssh/support/ssh_tunnel_bug.rb +65 -0
  173. data/plugins/project/vendor/net-ssh/test/README.txt +42 -0
  174. data/plugins/project/vendor/net-ssh/test/authentication/methods/common.rb +28 -0
  175. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  176. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  177. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  178. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_password.rb +50 -0
  179. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  180. data/plugins/project/vendor/net-ssh/test/authentication/test_agent.rb +205 -0
  181. data/plugins/project/vendor/net-ssh/test/authentication/test_key_manager.rb +105 -0
  182. data/plugins/project/vendor/net-ssh/test/authentication/test_session.rb +93 -0
  183. data/plugins/project/vendor/net-ssh/test/common.rb +107 -0
  184. data/plugins/project/vendor/net-ssh/test/configs/eqsign +3 -0
  185. data/plugins/project/vendor/net-ssh/test/configs/exact_match +8 -0
  186. data/plugins/project/vendor/net-ssh/test/configs/host_plus +10 -0
  187. data/plugins/project/vendor/net-ssh/test/configs/multihost +4 -0
  188. data/plugins/project/vendor/net-ssh/test/configs/nohost +19 -0
  189. data/plugins/project/vendor/net-ssh/test/configs/numeric_host +4 -0
  190. data/plugins/project/vendor/net-ssh/test/configs/wild_cards +14 -0
  191. data/plugins/project/vendor/net-ssh/test/connection/test_channel.rb +467 -0
  192. data/plugins/project/vendor/net-ssh/test/connection/test_session.rb +488 -0
  193. data/plugins/project/vendor/net-ssh/test/manual/test_forward.rb +185 -0
  194. data/plugins/project/vendor/net-ssh/test/test_all.rb +9 -0
  195. data/plugins/project/vendor/net-ssh/test/test_buffer.rb +336 -0
  196. data/plugins/project/vendor/net-ssh/test/test_buffered_io.rb +63 -0
  197. data/plugins/project/vendor/net-ssh/test/test_config.rb +117 -0
  198. data/plugins/project/vendor/net-ssh/test/test_key_factory.rb +67 -0
  199. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  200. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  201. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_none.rb +34 -0
  202. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  203. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  204. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  205. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  206. data/plugins/project/vendor/net-ssh/test/transport/test_algorithms.rb +302 -0
  207. data/plugins/project/vendor/net-ssh/test/transport/test_cipher_factory.rb +213 -0
  208. data/plugins/project/vendor/net-ssh/test/transport/test_hmac.rb +34 -0
  209. data/plugins/project/vendor/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  210. data/plugins/project/vendor/net-ssh/test/transport/test_packet_stream.rb +441 -0
  211. data/plugins/project/vendor/net-ssh/test/transport/test_server_version.rb +78 -0
  212. data/plugins/project/vendor/net-ssh/test/transport/test_session.rb +315 -0
  213. data/plugins/project/vendor/net-ssh/test/transport/test_state.rb +173 -0
  214. data/plugins/redcar/plugin.rb +3 -1
  215. data/plugins/redcar/redcar.rb +108 -121
  216. data/plugins/redcar_debug/lib/redcar_debug.rb +2 -0
  217. data/plugins/runnables/lib/runnables.rb +80 -23
  218. data/plugins/runnables/lib/runnables/command_output_controller.rb +102 -0
  219. data/plugins/runnables/lib/runnables/running_process_checker.rb +34 -0
  220. data/plugins/runnables/{plugin_no_load.rb → plugin.rb} +2 -1
  221. data/plugins/runnables/vendor/session-2.4.0/HISTORY +73 -0
  222. data/plugins/runnables/vendor/session-2.4.0/README +89 -0
  223. data/plugins/runnables/vendor/session-2.4.0/TODO +3 -0
  224. data/plugins/runnables/vendor/session-2.4.0/VERSION +1 -0
  225. data/plugins/runnables/vendor/session-2.4.0/gemspec.rb +22 -0
  226. data/plugins/runnables/vendor/session-2.4.0/install.rb +143 -0
  227. data/plugins/runnables/vendor/session-2.4.0/lib/session.rb +757 -0
  228. data/plugins/runnables/vendor/session-2.4.0/sample/bash.rb +60 -0
  229. data/plugins/runnables/vendor/session-2.4.0/sample/driver.rb +47 -0
  230. data/plugins/runnables/vendor/session-2.4.0/sample/session_idl.rb +25 -0
  231. data/plugins/runnables/vendor/session-2.4.0/sample/session_sh.rb +29 -0
  232. data/plugins/runnables/vendor/session-2.4.0/sample/sh0.rb +23 -0
  233. data/plugins/runnables/vendor/session-2.4.0/sample/stdin.rb +17 -0
  234. data/plugins/runnables/vendor/session-2.4.0/sample/threadtest.rb +42 -0
  235. data/plugins/runnables/vendor/session-2.4.0/session-2.4.0.gem +0 -0
  236. data/plugins/runnables/vendor/session-2.4.0/test/session.rb +227 -0
  237. data/plugins/runnables/views/command_output.html.erb +32 -0
  238. data/plugins/task_manager/lib/task_manager.rb +2 -0
  239. data/plugins/textmate/lib/textmate/plist.rb +1 -1
  240. data/plugins/textmate/lib/textmate/snippet.rb +1 -0
  241. data/plugins/tree/lib/tree/mirror.rb +8 -1
  242. data/plugins/tree_view_swt/lib/tree_view_swt.rb +29 -2
  243. metadata +191 -6
  244. data/plugins/declarations/TODO +0 -3
  245. data/plugins/redcar/spec/redcar/redcar_spec.rb +0 -70
  246. data/plugins/redcar/spec/spec_helper.rb +0 -4
@@ -0,0 +1,43 @@
1
+ module Net; module SFTP; module Protocol; module V01
2
+
3
+ # Represents a single named item on the remote server. This includes the
4
+ # name, attributes about the item, and the "longname", which is intended
5
+ # for use when displaying directory data, and has no specified format.
6
+ class Name
7
+ # The name of the item on the remote server.
8
+ attr_reader :name
9
+
10
+ # The display-ready name of the item, possibly with other attributes.
11
+ attr_reader :longname
12
+
13
+ # The Attributes object describing this item.
14
+ attr_reader :attributes
15
+
16
+ # Create a new Name object with the given name, longname, and attributes.
17
+ def initialize(name, longname, attributes)
18
+ @name, @longname, @attributes = name, longname, attributes
19
+ end
20
+
21
+ # Returns +true+ if the item appears to be a directory. It does this by
22
+ # examining the attributes. If there is insufficient information in the
23
+ # attributes, this will return nil, rather than a boolean.
24
+ def directory?
25
+ attributes.directory?
26
+ end
27
+
28
+ # Returns +true+ if the item appears to be a symlink. It does this by
29
+ # examining the attributes. If there is insufficient information in the
30
+ # attributes, this will return nil, rather than a boolean.
31
+ def symlink?
32
+ attributes.symlink?
33
+ end
34
+
35
+ # Returns +true+ if the item appears to be a regular file. It does this by
36
+ # examining the attributes. If there is insufficient information in the
37
+ # attributes, this will return nil, rather than a boolean.
38
+ def file?
39
+ attributes.file?
40
+ end
41
+ end
42
+
43
+ end; end; end; end
@@ -0,0 +1,31 @@
1
+ require 'net/sftp/protocol/01/base'
2
+
3
+ module Net; module SFTP; module Protocol; module V02
4
+
5
+ # Wraps the low-level SFTP calls for version 2 of the SFTP protocol.
6
+ #
7
+ # None of these protocol methods block--all of them return immediately,
8
+ # requiring the SSH event loop to be run while the server response is
9
+ # pending.
10
+ #
11
+ # You will almost certainly never need to use this driver directly. Please
12
+ # see Net::SFTP::Session for the recommended interface.
13
+ class Base < V01::Base
14
+
15
+ # Returns the protocol version implemented by this driver. (2, in this
16
+ # case)
17
+ def version
18
+ 2
19
+ end
20
+
21
+ # Sends a FXP_RENAME packet to the server to request that the file or
22
+ # directory with the given +name+ (must be a full path) be changed to
23
+ # +new_name+ (which must also be a path). The +flags+ parameter is
24
+ # ignored in this version of the protocol.
25
+ def rename(name, new_name, flags=nil)
26
+ send_request(FXP_RENAME, :string, name, :string, new_name)
27
+ end
28
+
29
+ end
30
+
31
+ end; end; end; end
@@ -0,0 +1,35 @@
1
+ require 'net/sftp/protocol/02/base'
2
+
3
+ module Net; module SFTP; module Protocol; module V03
4
+
5
+ # Wraps the low-level SFTP calls for version 3 of the SFTP protocol.
6
+ #
7
+ # None of these protocol methods block--all of them return immediately,
8
+ # requiring the SSH event loop to be run while the server response is
9
+ # pending.
10
+ #
11
+ # You will almost certainly never need to use this driver directly. Please
12
+ # see Net::SFTP::Session for the recommended interface.
13
+ class Base < V02::Base
14
+
15
+ # Returns the protocol version implemented by this driver. (3, in this
16
+ # case)
17
+ def version
18
+ 3
19
+ end
20
+
21
+ # Sends a FXP_READLINK packet to the server to request that the target of
22
+ # the given symlink on the remote host (+path+) be returned.
23
+ def readlink(path)
24
+ send_request(FXP_READLINK, :string, path)
25
+ end
26
+
27
+ # Sends a FXP_SYMLINK packet to the server to request that a symlink at the
28
+ # given +path+ be created, pointing at +target+..
29
+ def symlink(path, target)
30
+ send_request(FXP_SYMLINK, :string, path, :string, target)
31
+ end
32
+
33
+ end
34
+
35
+ end; end; end; end
@@ -0,0 +1,152 @@
1
+ require 'net/sftp/protocol/01/attributes'
2
+
3
+ module Net; module SFTP; module Protocol; module V04
4
+
5
+ # A class representing the attributes of a file or directory on the server.
6
+ # It may be used to specify new attributes, or to query existing attributes.
7
+ # This particular class is specific to versions 4 and 5 of the SFTP
8
+ # protocol.
9
+ #
10
+ # To specify new attributes, just pass a hash as the argument to the
11
+ # constructor. The following keys are supported:
12
+ #
13
+ # * :type:: the type of the item (integer, one of the T_ constants)
14
+ # * :size:: the size of the item (integer)
15
+ # * :uid:: the user-id that owns the file (integer)
16
+ # * :gid:: the group-id that owns the file (integer)
17
+ # * :owner:: the name of the user that owns the file (string)
18
+ # * :group:: the name of the group that owns the file (string)
19
+ # * :permissions:: the permissions on the file (integer, e.g. 0755)
20
+ # * :atime:: the access time of the file (integer, seconds since epoch)
21
+ # * :atime_nseconds:: the nanosecond component of atime (integer)
22
+ # * :createtime:: the time at which the file was created (integer, seconds since epoch)
23
+ # * :createtime_nseconds:: the nanosecond component of createtime (integer)
24
+ # * :mtime:: the modification time of the file (integer, seconds since epoch)
25
+ # * :mtime_nseconds:: the nanosecond component of mtime (integer)
26
+ # * :acl:: an array of ACL entries for the item
27
+ # * :extended:: a hash of name/value pairs identifying extended info
28
+ #
29
+ # Likewise, when the server sends an Attributes object, all of the
30
+ # above attributes are exposed as methods (though not all will be set with
31
+ # non-nil values from the server).
32
+ class Attributes < V01::Attributes
33
+
34
+ F_ACCESSTIME = 0x00000008
35
+ F_CREATETIME = 0x00000010
36
+ F_MODIFYTIME = 0x00000020
37
+ F_ACL = 0x00000040
38
+ F_OWNERGROUP = 0x00000080
39
+ F_SUBSECOND_TIMES = 0x00000100
40
+
41
+ # A simple struct for representing a single entry in an Access Control
42
+ # List. (See Net::SFTP::Constants::ACE)
43
+ ACL = Struct.new(:type, :flag, :mask, :who)
44
+
45
+ class <<self
46
+ # The list of supported elements in the attributes structure as defined
47
+ # by v4 of the sftp protocol.
48
+ def elements #:nodoc:
49
+ @elements ||= [
50
+ [:type, :byte, 0],
51
+ [:size, :int64, V01::Attributes::F_SIZE],
52
+ [:owner, :string, F_OWNERGROUP],
53
+ [:group, :string, F_OWNERGROUP],
54
+ [:permissions, :long, V01::Attributes::F_PERMISSIONS],
55
+ [:atime, :int64, F_ACCESSTIME],
56
+ [:atime_nseconds, :long, F_ACCESSTIME | F_SUBSECOND_TIMES],
57
+ [:createtime, :int64, F_CREATETIME],
58
+ [:createtime_nseconds, :long, F_CREATETIME | F_SUBSECOND_TIMES],
59
+ [:mtime, :int64, F_MODIFYTIME],
60
+ [:mtime_nseconds, :long, F_MODIFYTIME | F_SUBSECOND_TIMES],
61
+ [:acl, :special, F_ACL],
62
+ [:extended, :special, V01::Attributes::F_EXTENDED]
63
+ ]
64
+ end
65
+
66
+ private
67
+
68
+ # A helper method for parsing the ACL entry in an Attributes struct.
69
+ def parse_acl(buffer)
70
+ acl_buf = Net::SSH::Buffer.new(buffer.read_string)
71
+ acl = []
72
+ acl_buf.read_long.times do
73
+ acl << ACL.new(acl_buf.read_long, acl_buf.read_long, acl_buf.read_long, acl_buf.read_string)
74
+ end
75
+ acl
76
+ end
77
+ end
78
+
79
+ # The type of the item on the remote server. Must be one of the T_* constants.
80
+ attr_accessor :type
81
+
82
+ # The owner of the item on the remote server, as a string.
83
+ attr_writer :owner
84
+
85
+ # The group of the item on the remote server, as a string.
86
+ attr_writer :group
87
+
88
+ # The nanosecond component of the access time.
89
+ attr_accessor :atime_nseconds
90
+
91
+ # The creation time of the remote item, in seconds since the epoch.
92
+ attr_accessor :createtime
93
+
94
+ # The nanosecond component of the creation time.
95
+ attr_accessor :createtime_nseconds
96
+
97
+ # The nanosecond component of the modification time.
98
+ attr_accessor :mtime_nseconds
99
+
100
+ # The array of access control entries for this item.
101
+ attr_accessor :acl
102
+
103
+ # Create a new Attributes instance with the given attributes. The
104
+ # following keys are supported:
105
+ #
106
+ # * :type:: the type of the item (integer, one of the T_ constants)
107
+ # * :size:: the size of the item (integer)
108
+ # * :uid:: the user-id that owns the file (integer)
109
+ # * :gid:: the group-id that owns the file (integer)
110
+ # * :owner:: the name of the user that owns the file (string)
111
+ # * :group:: the name of the group that owns the file (string)
112
+ # * :permissions:: the permissions on the file (integer, e.g. 0755)
113
+ # * :atime:: the access time of the file (integer, seconds since epoch)
114
+ # * :atime_nseconds:: the nanosecond component of atime (integer)
115
+ # * :createtime:: the time at which the file was created (integer, seconds since epoch)
116
+ # * :createtime_nseconds:: the nanosecond component of createtime (integer)
117
+ # * :mtime:: the modification time of the file (integer, seconds since epoch)
118
+ # * :mtime_nseconds:: the nanosecond component of mtime (integer)
119
+ # * :acl:: an array of ACL entries for the item
120
+ # * :extended:: a hash of name/value pairs identifying extended info
121
+ #
122
+ # All of them default to +nil+ if omitted, except for +type+, which defaults
123
+ # to T_REGULAR.
124
+ def initialize(attributes={})
125
+ super
126
+ attributes[:type] ||= T_REGULAR
127
+ end
128
+
129
+ private
130
+
131
+ # Perform protocol-version-specific preparations for serialization.
132
+ def prepare_serialization!
133
+ # force the group/owner to be translated from uid/gid, if those keys
134
+ # were given on instantiation
135
+ owner
136
+ group
137
+ end
138
+
139
+ # Performs protocol-version-specific encoding of the access control
140
+ # list, if one exists.
141
+ def encode_acl(buffer)
142
+ acl_buf = Net::SSH::Buffer.from(:long, acl.length)
143
+ acl.each do |item|
144
+ acl_buf.write_long item.type, item.flag, item.mask
145
+ acl_buf.write_string item.who
146
+ end
147
+ buffer.write_string(acl_buf.to_s)
148
+ end
149
+
150
+ end
151
+
152
+ end ; end ; end ; end
@@ -0,0 +1,94 @@
1
+ require 'net/sftp/protocol/03/base'
2
+ require 'net/sftp/protocol/04/attributes'
3
+ require 'net/sftp/protocol/04/name'
4
+
5
+ module Net; module SFTP; module Protocol; module V04
6
+
7
+ # Wraps the low-level SFTP calls for version 4 of the SFTP protocol. Also
8
+ # implements the updated FXP_NAME packet parsing as mandated by v4 of the
9
+ # protocol.
10
+ #
11
+ # None of these protocol methods block--all of them return immediately,
12
+ # requiring the SSH event loop to be run while the server response is
13
+ # pending.
14
+ #
15
+ # You will almost certainly never need to use this driver directly. Please
16
+ # see Net::SFTP::Session for the recommended interface.
17
+ class Base < V03::Base
18
+
19
+ # Returns the protocol version implemented by this driver. (4, in this
20
+ # case)
21
+ def version
22
+ 4
23
+ end
24
+
25
+ # As of v4 of the SFTP protocol, the "longname" member was removed from the
26
+ # FXP_NAME structure. This method is essentially the same as the previous
27
+ # implementation, but omits longname.
28
+ def parse_name_packet(packet)
29
+ names = []
30
+
31
+ packet.read_long.times do
32
+ filename = packet.read_string
33
+ attrs = attribute_factory.from_buffer(packet)
34
+ names << name_factory.new(filename, attrs)
35
+ end
36
+
37
+ { :names => names }
38
+ end
39
+
40
+ # Sends a FXP_STAT packet to the server for the given +path+, and with the
41
+ # given +flags+. If +flags+ is nil, it defaults to F_SIZE | F_PERMISSIONS |
42
+ # F_ACCESSTIME | F_CREATETIME | F_MODIFYTIME | F_ACL | F_OWNERGROUP |
43
+ # F_SUBSECOND_TIMES | F_EXTENDED (see Net::SFTP::Protocol::V04::Attributes
44
+ # for those constants).
45
+ def stat(path, flags=nil)
46
+ send_request(FXP_STAT, :string, path, :long, flags || DEFAULT_FLAGS)
47
+ end
48
+
49
+ # Sends a FXP_LSTAT packet to the server for the given +path+, and with the
50
+ # given +flags+. If +flags+ is nil, it defaults to F_SIZE | F_PERMISSIONS |
51
+ # F_ACCESSTIME | F_CREATETIME | F_MODIFYTIME | F_ACL | F_OWNERGROUP |
52
+ # F_SUBSECOND_TIMES | F_EXTENDED (see Net::SFTP::Protocol::V04::Attributes
53
+ # for those constants).
54
+ def lstat(path, flags=nil)
55
+ send_request(FXP_LSTAT, :string, path, :long, flags || DEFAULT_FLAGS)
56
+ end
57
+
58
+ # Sends a FXP_FSTAT packet to the server for the given +path+, and with the
59
+ # given +flags+. If +flags+ is nil, it defaults to F_SIZE | F_PERMISSIONS |
60
+ # F_ACCESSTIME | F_CREATETIME | F_MODIFYTIME | F_ACL | F_OWNERGROUP |
61
+ # F_SUBSECOND_TIMES | F_EXTENDED (see Net::SFTP::Protocol::V04::Attributes
62
+ # for those constants).
63
+ def fstat(handle, flags=nil)
64
+ send_request(FXP_FSTAT, :string, handle, :long, flags || DEFAULT_FLAGS)
65
+ end
66
+
67
+ protected
68
+
69
+ # The default flags used if the +flags+ parameter is nil for any of the
70
+ # #stat, #lstat, or #fstat operations.
71
+ DEFAULT_FLAGS = Attributes::F_SIZE |
72
+ Attributes::F_PERMISSIONS |
73
+ Attributes::F_ACCESSTIME |
74
+ Attributes::F_CREATETIME |
75
+ Attributes::F_MODIFYTIME |
76
+ Attributes::F_ACL |
77
+ Attributes::F_OWNERGROUP |
78
+ Attributes::F_SUBSECOND_TIMES |
79
+ Attributes::F_EXTENDED
80
+
81
+ # Returns the Attributes class used by this version of the protocol
82
+ # (Net::SFTP::Protocol::V04::Attributes, in this case)
83
+ def attribute_factory
84
+ V04::Attributes
85
+ end
86
+
87
+ # Returns the Name class used by this version of the protocol
88
+ # (Net::SFTP::Protocol::V04::Name, in this case)
89
+ def name_factory
90
+ V04::Name
91
+ end
92
+ end
93
+
94
+ end; end; end; end
@@ -0,0 +1,67 @@
1
+ module Net; module SFTP; module Protocol; module V04
2
+
3
+ # Represents a single named item on the remote server. This includes the
4
+ # name, and attributes about the item, and the "longname".
5
+ #
6
+ # For backwards compatibility with the format and interface of the Name
7
+ # structure from previous protocol versions, this also exposes a #longname
8
+ # method, which returns a string that can be used to display this item in
9
+ # a directory listing.
10
+ class Name
11
+ # The name of the item on the remote server.
12
+ attr_reader :name
13
+
14
+ # Attributes instance describing this item.
15
+ attr_reader :attributes
16
+
17
+ # Create a new Name object with the given name and attributes.
18
+ def initialize(name, attributes)
19
+ @name, @attributes = name, attributes
20
+ end
21
+
22
+ # Returns +true+ if the item is a directory.
23
+ def directory?
24
+ attributes.directory?
25
+ end
26
+
27
+ # Returns +true+ if the item is a symlink.
28
+ def symlink?
29
+ attributes.symlink?
30
+ end
31
+
32
+ # Returns +true+ if the item is a regular file.
33
+ def file?
34
+ attributes.file?
35
+ end
36
+
37
+ # Returns a string representing this file, in a format similar to that
38
+ # used by the unix "ls" utility.
39
+ def longname
40
+ @longname ||= begin
41
+ longname = if directory?
42
+ "d"
43
+ elsif symlink?
44
+ "l"
45
+ else
46
+ "-"
47
+ end
48
+
49
+ longname << (attributes.permissions & 0400 != 0 ? "r" : "-")
50
+ longname << (attributes.permissions & 0200 != 0 ? "w" : "-")
51
+ longname << (attributes.permissions & 0100 != 0 ? "x" : "-")
52
+ longname << (attributes.permissions & 0040 != 0 ? "r" : "-")
53
+ longname << (attributes.permissions & 0020 != 0 ? "w" : "-")
54
+ longname << (attributes.permissions & 0010 != 0 ? "x" : "-")
55
+ longname << (attributes.permissions & 0004 != 0 ? "r" : "-")
56
+ longname << (attributes.permissions & 0002 != 0 ? "w" : "-")
57
+ longname << (attributes.permissions & 0001 != 0 ? "x" : "-")
58
+
59
+ longname << (" %-8s %-8s %8d " % [attributes.owner, attributes.group, attributes.size])
60
+
61
+ longname << Time.at(attributes.mtime).strftime("%b %e %H:%M ")
62
+ longname << name
63
+ end
64
+ end
65
+ end
66
+
67
+ end; end; end; end
@@ -0,0 +1,66 @@
1
+ require 'net/sftp/protocol/04/base'
2
+
3
+ module Net; module SFTP; module Protocol; module V05
4
+
5
+ # Wraps the low-level SFTP calls for version 5 of the SFTP protocol.
6
+ #
7
+ # None of these protocol methods block--all of them return immediately,
8
+ # requiring the SSH event loop to be run while the server response is
9
+ # pending.
10
+ #
11
+ # You will almost certainly never need to use this driver directly. Please
12
+ # see Net::SFTP::Session for the recommended interface.
13
+ class Base < V04::Base
14
+ # Returns the protocol version implemented by this driver. (5, in this
15
+ # case)
16
+ def version
17
+ 5
18
+ end
19
+
20
+ # Sends a FXP_RENAME packet to the server to request that the file or
21
+ # directory with the given +name+ (must be a full path) be changed to
22
+ # +new_name+ (which must also be a path). The +flags+ parameter must be
23
+ # either +nil+ or 0 (the default), or some combination of the
24
+ # Net::SFTP::Constants::RenameFlags constants.
25
+ def rename(name, new_name, flags=nil)
26
+ send_request(FXP_RENAME, :string, name, :string, new_name, :long, flags || 0)
27
+ end
28
+
29
+ # Sends a FXP_OPEN packet to the server and returns the packet identifier.
30
+ # The +flags+ parameter is either an integer (in which case it must be
31
+ # a combination of the IO constants) or a string (in which case it must
32
+ # be one of the mode strings that IO::open accepts). The +options+
33
+ # parameter is a hash that is used to construct a new Attribute object,
34
+ # to pass as part of the FXP_OPEN request.
35
+ def open(path, flags, options)
36
+ flags = normalize_open_flags(flags)
37
+
38
+ sftp_flags, desired_access = if flags & (IO::WRONLY | IO::RDWR) != 0
39
+ open = if flags & (IO::CREAT | IO::EXCL) == (IO::CREAT | IO::EXCL)
40
+ FV5::CREATE_NEW
41
+ elsif flags & (IO::CREAT | IO::TRUNC) == (IO::CREAT | IO::TRUNC)
42
+ FV5::CREATE_TRUNCATE
43
+ elsif flags & IO::CREAT == IO::CREAT
44
+ FV5::OPEN_OR_CREATE
45
+ else
46
+ FV5::OPEN_EXISTING
47
+ end
48
+ access = ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES
49
+ access |= ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES if (flags & IO::RDWR) == IO::RDWR
50
+ if flags & IO::APPEND == IO::APPEND
51
+ open |= FV5::APPEND_DATA
52
+ access |= ACE::Mask::APPEND_DATA
53
+ end
54
+ [open, access]
55
+ else
56
+ [FV5::OPEN_EXISTING, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES]
57
+ end
58
+
59
+ attributes = attribute_factory.new(options)
60
+
61
+ send_request(FXP_OPEN, :string, path, :long, desired_access, :long, sftp_flags, :raw, attributes.to_s)
62
+ end
63
+
64
+ end
65
+
66
+ end; end; end; end