Class: GitHubPrivateRepositoryReleaseDownloadStrategy

Inherits:
GitHubPrivateRepositoryDownloadStrategy show all
Defined in:
Library/Homebrew/download_strategy.rb

Overview

GitHubPrivateRepositoryReleaseDownloadStrategy downloads tarballs from GitHub Release assets. To use it, add “:using => GitHubPrivateRepositoryReleaseDownloadStrategy” to the URL section of your formula. This download strategy uses GitHub access tokens (in the environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request.

Instance Attribute Summary

Attributes inherited from CurlDownloadStrategy

#mirrors, #tarball_path, #temporary_path

Attributes inherited from AbstractDownloadStrategy

#cached_location, #meta, #name, #resource, #shutup, #version

Instance Method Summary collapse

Methods inherited from GitHubPrivateRepositoryDownloadStrategy

#initialize

Methods inherited from CurlDownloadStrategy

#cached_location, #clear_cache, #fetch, #initialize

Methods inherited from AbstractFileDownloadStrategy

#stage

Methods inherited from AbstractDownloadStrategy

#clear_cache, #expand_safe_system_args, #fetch, #initialize, #ohai, #puts, #quiet_safe_system, #safe_system, #shutup!, #source_modified_time, #stage

Methods included from FileUtils

#make, mkdir, mktemp, #old_mkdir, #old_ruby, #ruby, #scons, #xcodebuild

Constructor Details

This class inherits a constructor from GitHubPrivateRepositoryDownloadStrategy

Instance Method Details

#_fetchObject



581
582
583
584
585
# File 'Library/Homebrew/download_strategy.rb', line 581

def _fetch
  # HTTP request header `Accept: application/octet-stream` is required.
  # Without this, the GitHub API will respond with metadata, not binary.
  curl_download download_url, "--header", "Accept: application/octet-stream", to: temporary_path
end

#download_urlObject



577
578
579
# File 'Library/Homebrew/download_strategy.rb', line 577

def download_url
  "https://#{@github_token}@api.github.com/repos/#{@owner}/#{@repo}/releases/assets/#{asset_id}"
end

#parse_url_patternObject



568
569
570
571
572
573
574
575
# File 'Library/Homebrew/download_strategy.rb', line 568

def parse_url_pattern
  url_pattern = %r{https://github.com/([^/]+)/([^/]+)/releases/download/([^/]+)/(\S+)}
  unless @url =~ url_pattern
    raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release."
  end

  _, @owner, @repo, @tag, @filename = *@url.match(url_pattern)
end