lib/autobuild/import/tar.rb in autobuild-0.6.7 vs lib/autobuild/import/tar.rb in autobuild-1.0

- old
+ new

@@ -14,21 +14,22 @@ Gzip => 'z', Bzip => 'j' } # Known URI schemes for +url+ - VALID_URI_SCHEMES = [ 'file', 'http', 'ftp' ] + VALID_URI_SCHEMES = [ 'file', 'http', 'https', 'ftp' ] # Returns the unpack mode from the file name def self.url_to_mode(url) ext = File.extname(url) unless ext == '.tar' raise "Invalid file type in #{url}" unless File.basename(url, ext) != '.tar' end mode = case ext when '.tar'; Plain - when '.gz'; Gzip + when '.gz'; Gzip + when '.tgz'; Gzip when '.bz2'; Bzip end mode end @@ -74,17 +75,17 @@ end # Sets the source URL and update +cachefile+ and +mode+ attributes accordingly. def url=(url) @url = URI.parse(url) - raise ConfigException, "invalid URL #{url}" unless VALID_URI_SCHEMES.include?(@url.scheme) + raise ConfigException, "invalid URL #{url}" unless VALID_URI_SCHEMES.include?(url.scheme) @mode = TarImporter.url_to_mode(url) - if @url.scheme == 'file' - @cachefile = @url + if url.scheme == 'file' + @cachefile = url else - @cachefile = File.join(cachedir, File.basename(@url.path)) + @cachefile = File.join(cachedir, File.basename(url.path)) end end # The source URL attr_reader :url @@ -103,10 +104,10 @@ @options[:cachedir] ||= "#{Autobuild.prefix}/cache" self.url = url end def update(package) # :nodoc: - checkout if update_cache + checkout(package) if update_cache rescue OpenURI::HTTPError raise Autobuild::Exception.new(package.name, :import) end def checkout(package) # :nodoc: