Class: Pod::Downloader::GitHub

Inherits:
Git show all
Defined in:
lib/cocoapods/downloader/git.rb

Constant Summary

Constant Summary

Constants inherited from Git

Pod::Downloader::Git::MAX_CACHE_SIZE

Instance Attribute Summary

Attributes inherited from Pod::Downloader

#options, #target_path, #url

Instance Method Summary (collapse)

Methods inherited from Git

#cache_exist?, #cache_path, #caches_dir, #caches_size, #clone_url, #create_cache, #download, #ensure_ref_exists, #origin_url, #ref_exists?, #removed_cached_repos_if_needed, #update_cache

Methods included from Config::Mixin

#config

Methods inherited from Pod::Downloader

for_pod, for_target, #initialize

Methods included from Executable

#executable

Constructor Details

This class inherits a constructor from Pod::Downloader

Instance Method Details

- (Object) download_and_extract_tarball(id) (private)



145
146
147
148
149
150
151
152
153
# File 'lib/cocoapods/downloader/git.rb', line 145

def download_and_extract_tarball(id)
  File.open(tmp_path, "w+") do |tmpfile|
    open tarball_url_for(id) do |archive|
      tmpfile.write Zlib::GzipReader.new(archive).read
    end

    system "tar xf #{tmpfile.path} -C #{target_path} --strip-components 1"
  end
end

- (Object) download_commit



126
127
128
# File 'lib/cocoapods/downloader/git.rb', line 126

def download_commit
  download_only? ? download_and_extract_tarball(options[:commit]) : super
end

- (Object) download_head



118
119
120
# File 'lib/cocoapods/downloader/git.rb', line 118

def download_head
  download_only? ? download_and_extract_tarball('master') : super
end

- (Boolean) download_only? (private)

Returns:

  • (Boolean)


141
142
143
# File 'lib/cocoapods/downloader/git.rb', line 141

def download_only?
  @options[:download_only]
end

- (Object) download_tag



122
123
124
# File 'lib/cocoapods/downloader/git.rb', line 122

def download_tag
  download_only? ? download_and_extract_tarball(options[:tag]) : super
end

- (Object) tarball_url_for(id)



130
131
132
133
# File 'lib/cocoapods/downloader/git.rb', line 130

def tarball_url_for(id)
  original_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a)
  "https://github.com/#{username}/#{reponame}/tarball/#{id}"
end

- (Object) tmp_path



135
136
137
# File 'lib/cocoapods/downloader/git.rb', line 135

def tmp_path
  target_path + "tarball.tar.gz"
end