Commit 28e3ec47 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge pull request #522 from btaylor/master

Support extracting .tar.bz2 files
parents 5fdc01c1 85a9df78
...@@ -33,6 +33,8 @@ module Pod ...@@ -33,6 +33,8 @@ module Pod
:tgz :tgz
elsif url =~ /.tar$/ elsif url =~ /.tar$/
:tar :tar
elsif url =~ /.(tbz|tar\.bz2)$/
:tbz
else else
nil nil
end end
...@@ -46,6 +48,8 @@ module Pod ...@@ -46,6 +48,8 @@ module Pod
"file.tgz" "file.tgz"
when :tar when :tar
"file.tar" "file.tar"
when :tbz
"file.tbz"
else else
raise UnsupportedFileTypeError.new "Unsupported file type: #{type}" raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
end end
...@@ -63,6 +67,8 @@ module Pod ...@@ -63,6 +67,8 @@ module Pod
tar! "xfz '#{full_filename}' -C '#{target_path}'" tar! "xfz '#{full_filename}' -C '#{target_path}'"
when :tar when :tar
tar! "xf '#{full_filename}' -C '#{target_path}'" tar! "xf '#{full_filename}' -C '#{target_path}'"
when :tbz
tar! "xfj '#{full_filename}' -C '#{target_path}'"
else else
raise UnsupportedFileTypeError.new "Unsupported file type: #{type}" raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
end end
......
...@@ -32,6 +32,12 @@ describe Pod::Downloader::Http do ...@@ -32,6 +32,12 @@ describe Pod::Downloader::Http do
downloader.should.be.instance_of Pod::Downloader::Http downloader.should.be.instance_of Pod::Downloader::Http
downloader.type.should == :tgz 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( downloader = Pod::Downloader.for_pod(stub_pod_with_source(
:http => 'https://testflightapp.com/media/sdk-downloads/TestFlightSDK1.0', :http => 'https://testflightapp.com/media/sdk-downloads/TestFlightSDK1.0',
:type => :zip :type => :zip
...@@ -54,6 +60,13 @@ describe Pod::Downloader::Http do ...@@ -54,6 +60,13 @@ describe Pod::Downloader::Http do
downloader.expects(:download_file).with(anything()) downloader.expects(:download_file).with(anything())
downloader.expects(:extract_with_type).with(anything(), :tgz).at_least_once downloader.expects(:extract_with_type).with(anything(), :tgz).at_least_once
downloader.download 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 end
it 'should raise error when unsupported filetype is pass' do it 'should raise error when unsupported filetype is pass' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment