Sha256: 715eb8c89b458e655a7ecca942f5e55bea81a465231ab0f07b76bee5b3a56d8a
Contents?: true
Size: 649 Bytes
Versions: 1
Compression:
Stored size: 649 Bytes
Contents
require 'open-uri' module Downlow class Http < Fetcher handles(/^https?\:\/\//) def fetch data = "" filename = destination.basename open(url.to_s) do |u| if disposition = u.meta['content-disposition'] and disposition.match(/filename=\"([^\"]+)\"/) filename = $1 else filename = Pathname.new(u.base_uri.to_s).basename end data << u.read end filename = filename.to_s.gsub(/\?(.*)$/,'') self.destination = destination.dirname + filename File.open(destination, 'w') {|f| f << data } @local_path = destination end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
downlow-0.1.4 | lib/downlow/fetchers/http.rb |