<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,14 +4,14 @@
 
 == DESCRIPTION:
 
-Net::SCP is a pure-Ruby implementation of the SCP protocol. This operates over SSH (and requires the Net::SSH library), and allows files and directory trees to copied toand from a remote server.
+Net::SCP is a pure-Ruby implementation of the SCP protocol. This operates over SSH (and requires the Net::SSH library), and allows files and directory trees to copied to and from a remote server.
 
 == FEATURES/PROBLEMS:
 
 * Transfer files or entire directory trees to or from a remote host via SCP
 * Can preserve file attributes across transfers
 * Can download files in-memory, or direct-to-disk
-* Support for OpenURI
+* Support for SCP URI's, and OpenURI
 
 == SYNOPSIS:
 </diff>
      <filename>README.txt</filename>
    </modified>
    <modified>
      <diff>@@ -6,12 +6,75 @@ require 'net/scp/upload'
 require 'net/scp/download'
 
 module Net
+
+  # Net::SCP implements the SCP (Secure CoPy) client protocol, allowing Ruby
+  # programs to securely and programmatically transfer individual files or
+  # entire directory trees to and from remote servers. It provides support for
+  # multiple simultaneous SCP copies working in parallel over the same
+  # connection, as well as for synchronous, serial copies.
+  #
+  # Basic usage:
+  #
+  #   require 'net/scp'
+  #
+  #   Net::SCP.start(&quot;remote.host&quot;, &quot;username&quot;, :password =&gt; &quot;passwd&quot;) do |scp|
+  #     # synchronous (blocking) upload; call blocks until upload completes
+  #     scp.upload! &quot;/local/path&quot;, &quot;/remote/path&quot;
+  #
+  #     # asynchronous upload; call returns immediately and requires SSH
+  #     # event loop to run
+  #     channel = scp.upload(&quot;/local/path&quot;, &quot;/remote/path&quot;)
+  #     channel.wait
+  #   end
+  #
+  # Net::SCP also provides an open-uri tie-in, so you can use the Kernel#open
+  # method to open and read a remote file:
+  #
+  #   # if you just want to parse SCP URL's:
+  #   require 'uri/scp'
+  #   url = URI.parse(&quot;scp://user@remote.host/path/to/file&quot;)
+  #
+  #   # if you want to read from a URL voa SCP:
+  #   require 'uri/open-scp'
+  #   puts open(&quot;scp://user@remote.host/path/to/file&quot;).read
+  #
+  # Lastly, Net::SCP adds a method to the Net::SSH::Connection::Session class,
+  # allowing you to easily grab a Net::SCP reference from an existing Net::SSH
+  # session:
+  #
+  #   require 'net/ssh'
+  #   require 'net/scp'
+  #
+  #   Net::SSH.start(&quot;remote.host&quot;, &quot;username&quot;, :password =&gt; &quot;passwd&quot;) do |ssh|
+  #     ssh.scp.download! &quot;/remote/path&quot;, &quot;/local/path&quot;
+  #   end
+  #
+  # == Progress Reporting
+  #
+  # By default, uploading and downloading proceed silently, without any
+  # outword indication of their progress. For long running uploads or downloads
+  # (and especially in interactive environments) it is desirable to report
+  # to the user the progress of the current operation.
+  #
+  # To receive progress reports for the current operation, just pass a block
+  # to #upload or #download (or one of their variants):
+  #
+  #   scp.upload!(&quot;/path/to/local&quot;, &quot;/path/to/remote&quot;) do |name, sent, total|
+  #     puts &quot;#{name}: #{sent}/#{total}&quot;
+  #   end
+  #
+  # Whenever a new chunk of data is recieved for or sent to a file, the callback
+  # will be invoked, indicating the name of the file (local for downloads,
+  # remote for uploads), the number of bytes that have been sent or received
+  # so far for the file, and the size of the file.
   class SCP
     include Net::SSH::Loggable
     include Upload, Download
 
-    # When all you want is a quick SCP reference and don't particularly need
-    # the associated SSH session, you can use the start method.
+    # Starts up a new SSH connection and instantiates a new SCP session on 
+    # top of it. If a block is given, the SCP session is yielded, and the
+    # SSH session is closed automatically when the block terminates. If no
+    # block is given, the SCP session is returned.
     def self.start(host, username, options={})
       session = Net::SSH.start(host, username, options)
       scp = new(session)
@@ -28,6 +91,13 @@ module Net
       end
     end
 
+    # Starts up a new SSH connection using the +host+ and +username+ parameters,
+    # instantiates a new SCP session on top of it, and then begins an
+    # upload from +local+ to +remote+. If the +options+ hash includes an
+    # :ssh key, the value for that will be passed to the SSH connection as
+    # options (e.g., to set the password, etc.). All other options are passed
+    # to the #upload! method. If a block is given, it will be used to report
+    # progress (see &quot;Progress Reporting&quot;, under Net::SCP).
     def self.upload!(host, username, local, remote, options={}, &amp;progress)
       options = options.dup
       start(host, username, options.delete(:ssh) || {}) do |scp|
@@ -35,6 +105,13 @@ module Net
       end
     end
 
+    # Starts up a new SSH connection using the +host+ and +username+ parameters,
+    # instantiates a new SCP session on top of it, and then begins a
+    # download from +remote+ to +local+. If the +options+ hash includes an
+    # :ssh key, the value for that will be passed to the SSH connection as
+    # options (e.g., to set the password, etc.). All other options are passed
+    # to the #download! method. If a block is given, it will be used to report
+    # progress (see &quot;Progress Reporting&quot;, under Net::SCP).
     def self.download!(host, username, remote, local=nil, options={}, &amp;progress)
       options = options.dup
       start(host, username, options.delete(:ssh) || {}) do |scp|
@@ -42,25 +119,77 @@ module Net
       end
     end
 
+    # The underlying Net::SSH session that acts as transport for the SCP
+    # packets.
     attr_reader :session
 
+    # Creates a new Net::SCP session on top of the given Net::SSH +session+
+    # object.
     def initialize(session)
       @session = session
       self.logger = session.logger
     end
 
+    # Inititiate a synchronous (non-blocking) upload from +local+ to +remote+.
+    # The following options are recognized:
+    #
+    # * :recursive - the +local+ parameter refers to a local directory, which
+    #   should be uploaded to a new directory named +remote+ on the remote
+    #   server.
+    # * :preserve - the atime and mtime of the file should be preserved.
+    # * :verbose - the process should result in verbose output on the server
+    #   end (useful for debugging).
+    # 
+    # This method will return immediately, returning the Net::SSH::Connection::Channel
+    # object that will support the upload. To wait for the upload to finish,
+    # you can either call the #wait method on the channel, or otherwise run
+    # the Net::SSH event loop until the channel's #active? method returns false.
+    #
+    #   channel = scp.upload(&quot;/local/path&quot;, &quot;/remote/path&quot;)
+    #   channel.wait
     def upload(local, remote, options={}, &amp;progress)
       start_command(:upload, local, remote, options, &amp;progress)
     end
 
+    # Same as #upload, but blocks until the upload finishes. Identical to
+    # calling #upload and then calling the #wait method on the channel object
+    # that is returned. The return value is not defined.
     def upload!(local, remote, options={}, &amp;progress)
       upload(local, remote, options, &amp;progress).wait
     end
 
+    # Inititiate a synchronous (non-blocking) download from +remote+ to +local+.
+    # The following options are recognized:
+    #
+    # * :recursive - the +remote+ parameter refers to a remote directory, which
+    #   should be downloaded to a new directory named +local+ on the local
+    #   machine.
+    # * :preserve - the atime and mtime of the file should be preserved.
+    # * :verbose - the process should result in verbose output on the server
+    #   end (useful for debugging).
+    # 
+    # This method will return immediately, returning the Net::SSH::Connection::Channel
+    # object that will support the download. To wait for the download to finish,
+    # you can either call the #wait method on the channel, or otherwise run
+    # the Net::SSH event loop until the channel's #active? method returns false.
+    #
+    #   channel = scp.download(&quot;/remote/path&quot;, &quot;/local/path&quot;)
+    #   channel.wait
     def download(remote, local, options={}, &amp;progress)
       start_command(:download, local, remote, options, &amp;progress)
     end
 
+    # Same as #download, but blocks until the download finishes. Identical to
+    # calling #download and then calling the #wait method on the channel
+    # object that is returned.
+    #
+    #   scp.download!(&quot;/remote/path&quot;, &quot;/local/path&quot;)
+    #
+    # If +local+ is nil, and the download is not recursive (e.g., it is downloading
+    # only a single file), the file will be downloaded to an in-memory buffer
+    # and the resulting string returned.
+    #
+    #   data = download!(&quot;/remote/path&quot;)
     def download!(remote, local=nil, options={}, &amp;progress)
       destination = local ? local : StringIO.new
       download(remote, destination, options, &amp;progress).wait</diff>
      <filename>lib/net/scp.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ module URI
     def buffer_open(buf, proxy, open_options)
       options = open_options.merge(:port =&gt; port, :password =&gt; password)
       progress = options.delete(:progress_proc)
-      buf &lt;&lt; Net::SCP.download(host, user, path, nil, open_options, &amp;progress)
+      buf &lt;&lt; Net::SCP.download!(host, user, path, nil, open_options, &amp;progress)
       buf.io.rewind
     end
 </diff>
      <filename>lib/uri/open-scp.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b90295cdbd469820ab3a3815e2ed0ab11e9072cb</id>
    </parent>
  </parents>
  <author>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </author>
  <url>http://github.com/jamis/net-scp/commit/415405aa5a4e8da5a249b821ef3f99ce0c73a0c4</url>
  <id>415405aa5a4e8da5a249b821ef3f99ce0c73a0c4</id>
  <committed-date>2008-03-15T19:49:53-07:00</committed-date>
  <authored-date>2008-03-15T19:49:53-07:00</authored-date>
  <message>go with bang convention for blocking calls. start adding more rdocs</message>
  <tree>addd261d5b8579f55e774c87a9ede8e44702d1ab</tree>
  <committer>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </committer>
</commit>
