Support extracting .tar.bz2 files #522

Merged
merged 1 commit into from Sep 18, 2012
@@ -33,6 +33,8 @@ def type_with_url(url)
:tgz
elsif url =~ /.tar$/
:tar
+ elsif url =~ /.(tbz|tar\.bz2)$/
+ :tbz
else
nil
end
@@ -46,6 +48,8 @@ def filename_with_type(type=:zip)
"file.tgz"
when :tar
"file.tar"
+ when :tbz
+ "file.tbz"
else
raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
end
@@ -63,6 +67,8 @@ def extract_with_type(full_filename, type=:zip)
tar! "xfz '#{full_filename}' -C '#{target_path}'"
when :tar
tar! "xf '#{full_filename}' -C '#{target_path}'"
+ when :tbz
+ tar! "xfj '#{full_filename}' -C '#{target_path}'"
else
raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
end
View
@@ -33,6 +33,12 @@ def stub_pod_with_source(source_options)
downloader.type.should == :tgz
downloader = Pod::Downloader.for_pod(stub_pod_with_source(
+ :http => 'http://www.kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.bz2'
+ ))
+ downloader.should.be.instance_of Pod::Downloader::Http
+ downloader.type.should == :tbz
+
+ downloader = Pod::Downloader.for_pod(stub_pod_with_source(
:http => 'https://testflightapp.com/media/sdk-downloads/TestFlightSDK1.0',
:type => :zip
))
@@ -54,6 +60,13 @@ def stub_pod_with_source(source_options)
downloader.expects(:download_file).with(anything())
downloader.expects(:extract_with_type).with(anything(), :tgz).at_least_once
downloader.download
+
+ downloader = Pod::Downloader.for_pod(stub_pod_with_source(
+ :http => 'http://www.kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.bz2'
+ ))
+ downloader.expects(:download_file).with(anything())
+ downloader.expects(:extract_with_type).with(anything(), :tbz).at_least_once
+ downloader.download
end
it 'should raise error when unsupported filetype is pass' do