From 4ac0a8de35315ea41ff71c77ef421977c274e452 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Tue, 12 Nov 2013 22:32:36 +0000 Subject: [PATCH] Support LZMA compressed tarballs --- lib/cocoapods-downloader/http.rb | 8 +++++++- spec/cocoapods-downloaders/http_spec.rb | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/cocoapods-downloader/http.rb b/lib/cocoapods-downloader/http.rb index 6dab289..559beb4 100644 --- a/lib/cocoapods-downloader/http.rb +++ b/lib/cocoapods-downloader/http.rb @@ -43,7 +43,7 @@ def type def should_flatten? if options.has_key?(:flatten) true - elsif [:tgz, :tar, :tbz].include?(type) + elsif [:tgz, :tar, :tbz, :txz].include?(type) true # those archives flatten by default else false # all others (actually only .zip) default not to flatten @@ -59,6 +59,8 @@ def type_with_url(url) :tar elsif url =~ /.(tbz|tar\.bz2)$/ :tbz + elsif url =~ /.(txz|tar\.xz)$/ + :txz else nil end @@ -74,6 +76,8 @@ def filename_with_type(type=:zip) "file.tar" when :tbz "file.tbz" + when :txz + "file.txz" else raise UnsupportedFileTypeError.new "Unsupported file type: #{type}" end @@ -93,6 +97,8 @@ def extract_with_type(full_filename, type=:zip) tar! "xf '#{full_filename}' -C '#{target_path}'" when :tbz tar! "xfj '#{full_filename}' -C '#{target_path}'" + when :txz + tar! "xf '#{full_filename}' -C '#{target_path}'" else raise UnsupportedFileTypeError.new "Unsupported file type: #{type}" end diff --git a/spec/cocoapods-downloaders/http_spec.rb b/spec/cocoapods-downloaders/http_spec.rb index 44cefef..575bf69 100644 --- a/spec/cocoapods-downloaders/http_spec.rb +++ b/spec/cocoapods-downloaders/http_spec.rb @@ -79,6 +79,12 @@ module Downloader downloader.send(:type).should == :tbz end + it 'detects txz files' do + options = { :http => 'https://file.txz' } + downloader = Downloader.for_target(tmp_folder, options) + downloader.send(:type).should == :txz + end + it 'allows to specify the file type in the sources' do options = { :http => 'https://file', :type => :zip } downloader = Downloader.for_target(tmp_folder, options)