Skip to content
This repository

Support extracting .tar.bz2 files #522

Merged
merged 1 commit into from almost 2 years ago

2 participants

Brad Taylor Fabio Pelosin
Brad Taylor

Chartboost (and likely other sites) distribute source code in bz2
format. Support for recognizing and extracting these files will come in
handy.

Brad Taylor btaylor Support extracting .tar.bz2 files
Chartboost (and likely other sites) distribute source code in bz2
format.  Support for recognizing and extracting these files will come in
handy.
85a9df7
Fabio Pelosin irrationalfab merged commit 28e3ec4 into from
Fabio Pelosin

Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 14, 2012
Brad Taylor btaylor Support extracting .tar.bz2 files
Chartboost (and likely other sites) distribute source code in bz2
format.  Support for recognizing and extracting these files will come in
handy.
85a9df7
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. +6 0 lib/cocoapods/downloader/http.rb
  2. +13 0 spec/unit/http_spec.rb
6 lib/cocoapods/downloader/http.rb
@@ -33,6 +33,8 @@ def type_with_url(url)
33 33 :tgz
34 34 elsif url =~ /.tar$/
35 35 :tar
  36 + elsif url =~ /.(tbz|tar\.bz2)$/
  37 + :tbz
36 38 else
37 39 nil
38 40 end
@@ -46,6 +48,8 @@ def filename_with_type(type=:zip)
46 48 "file.tgz"
47 49 when :tar
48 50 "file.tar"
  51 + when :tbz
  52 + "file.tbz"
49 53 else
50 54 raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
51 55 end
@@ -63,6 +67,8 @@ def extract_with_type(full_filename, type=:zip)
63 67 tar! "xfz '#{full_filename}' -C '#{target_path}'"
64 68 when :tar
65 69 tar! "xf '#{full_filename}' -C '#{target_path}'"
  70 + when :tbz
  71 + tar! "xfj '#{full_filename}' -C '#{target_path}'"
66 72 else
67 73 raise UnsupportedFileTypeError.new "Unsupported file type: #{type}"
68 74 end
13 spec/unit/http_spec.rb
@@ -33,6 +33,12 @@ def stub_pod_with_source(source_options)
33 33 downloader.type.should == :tgz
34 34
35 35 downloader = Pod::Downloader.for_pod(stub_pod_with_source(
  36 + :http => 'http://www.kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.bz2'
  37 + ))
  38 + downloader.should.be.instance_of Pod::Downloader::Http
  39 + downloader.type.should == :tbz
  40 +
  41 + downloader = Pod::Downloader.for_pod(stub_pod_with_source(
36 42 :http => 'https://testflightapp.com/media/sdk-downloads/TestFlightSDK1.0',
37 43 :type => :zip
38 44 ))
@@ -54,6 +60,13 @@ def stub_pod_with_source(source_options)
54 60 downloader.expects(:download_file).with(anything())
55 61 downloader.expects(:extract_with_type).with(anything(), :tgz).at_least_once
56 62 downloader.download
  63 +
  64 + downloader = Pod::Downloader.for_pod(stub_pod_with_source(
  65 + :http => 'http://www.kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.bz2'
  66 + ))
  67 + downloader.expects(:download_file).with(anything())
  68 + downloader.expects(:extract_with_type).with(anything(), :tbz).at_least_once
  69 + downloader.download
57 70 end
58 71
59 72 it 'should raise error when unsupported filetype is pass' do

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.