Sha256: 99f7adbe461129c2f0f4bf6d9035048604f38a55ccbf96b6cefff7f66a78971f

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# Copyright: Copyright (c) 2004  Nicolas Despres. All rights reserved.
# Author: Nicolas Despres  <polrop@lrde.epita.fr>.
# License: Gnu General Public License.

# $LastChangedBy: polrop $
# $Id: fetcher.rb 67 2004-12-07 01:00:10Z polrop $


require 'md5'


module Session

  module Fetcher

    #
    # Requests
    #
    def upload(local_filename, remote_filename)
      ret = false
      File.open(local_filename, 'r') do |f|
        md5 = Digest::MD5.new
        local_eof = false
        ret = request(:fetch, remote_filename, 'w') do
          if f.eof?
            unless local_eof
              local_eof = true
              nil
            else
              md5
            end
          else
            str = f.read(1024)
            md5 << str
            str
          end
        end
      end
      ret
    end

    def download(remote_filename, local_filename)
      ret = false
      File.open(local_filename, 'w') do |f|
        md5 = Digest::MD5.new
        ret = request(:fetch, remote_filename) do |str|
          if str.nil?
            md5
          else
            md5 << str
            f.write(str)
          end
        end
      end
      ret
    end

  end # Fetcher

end # module Session


Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ttk-0.1.576 ruby_ex/session/fetcher.rb
ttk-0.1.579 ruby_ex/session/fetcher.rb
ttk-0.1.580 ruby_ex/session/fetcher.rb
vcs-0.2.148 ruby_ex/session/fetcher.rb