Class: AbstractDownloadStrategy Abstract Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Context, FileUtils
Defined in:
Library/Homebrew/download_strategy.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is abstract.

Abstract superclass for all download strategies.

Defined Under Namespace

Modules: Pourable

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

#initialize(url, name, version, **meta) ⇒ AbstractDownloadStrategy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AbstractDownloadStrategy.


35
36
37
38
39
40
41
42
# File 'Library/Homebrew/download_strategy.rb', line 35

def initialize(url, name, version, **meta)
  @url = url
  @name = name
  @version = version
  @cache = meta.fetch(:cache, HOMEBREW_CACHE)
  @meta = meta
  extend Pourable if meta[:bottle]
end

Instance Attribute Details

#cacheObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


31
32
33
# File 'Library/Homebrew/download_strategy.rb', line 31

def cache
  @cache
end

#cached_locationObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


31
32
33
# File 'Library/Homebrew/download_strategy.rb', line 31

def cached_location
  @cached_location
end

#source_modified_timeObject (readonly)

Returns the most recent modified time for all files in the current working directory after stage.


90
91
92
# File 'Library/Homebrew/download_strategy.rb', line 90

def source_modified_time
  Pathname.pwd.to_enum(:find).select(&:file?).map(&:mtime).max
end

#urlObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


31
32
33
# File 'Library/Homebrew/download_strategy.rb', line 31

def url
  @url
end

Instance Method Details

#basenameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


102
103
104
# File 'Library/Homebrew/download_strategy.rb', line 102

def basename
  cached_location.basename
end

#clear_cacheObject

Remove #cached_location and any other files associated with the resource from the cache.


98
99
100
# File 'Library/Homebrew/download_strategy.rb', line 98

def clear_cache
  rm_rf(cached_location)
end

#fetchObject

Download and cache the resource at #cached_location.


47
# File 'Library/Homebrew/download_strategy.rb', line 47

def fetch; end

#shutup!Object

Disable any output during downloading.

TODO: Deprecate once we have an explicitly documented alternative.


54
55
56
# File 'Library/Homebrew/download_strategy.rb', line 54

def shutup!
  @quiet = true
end

#stageObject

Unpack #cached_location into the current working directory, and possibly chdir into the newly-unpacked directory. Unlike Resource#stage, this does not take a block.


63
64
65
66
67
68
69
70
71
# File 'Library/Homebrew/download_strategy.rb', line 63

def stage
  UnpackStrategy.detect(cached_location,
                        prioritise_extension: true,
                        ref_type: @ref_type, ref: @ref)
                .extract_nestedly(basename:             basename,
                                  prioritise_extension: true,
                                  verbose:              verbose? && !quiet?)
  chdir
end