Class: GitHubPrivateRepositoryDownloadStrategy

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

Overview

GitHubPrivateRepositoryDownloadStrategy downloads contents from GitHub Private Repository. To use it, add “:using => GitHubPrivateRepositoryDownloadStrategy” 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. This strategy is suitable for corporate use just like S3DownloadStrategy, because it lets you use a private GitHub repository for internal distribution. It works with public one, but in that case simply use CurlDownloadStrategy.

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 CurlDownloadStrategy

#cached_location, #clear_cache, #fetch

Methods inherited from AbstractFileDownloadStrategy

#stage

Methods inherited from AbstractDownloadStrategy

#clear_cache, #expand_safe_system_args, #fetch, #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

#initialize(name, resource) ⇒ GitHubPrivateRepositoryDownloadStrategy

Returns a new instance of GitHubPrivateRepositoryDownloadStrategy



515
516
517
518
519
# File 'Library/Homebrew/download_strategy.rb', line 515

def initialize(name, resource)
  super
  parse_url_pattern
  set_github_token
end

Instance Method Details

#_fetchObject



534
535
536
# File 'Library/Homebrew/download_strategy.rb', line 534

def _fetch
  curl_download download_url, to: temporary_path
end

#download_urlObject



530
531
532
# File 'Library/Homebrew/download_strategy.rb', line 530

def download_url
  "https://#{@github_token}@github.com/#{@owner}/#{@repo}/#{@filepath}"
end

#parse_url_patternObject



521
522
523
524
525
526
527
528
# File 'Library/Homebrew/download_strategy.rb', line 521

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

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