Class: Homebrew::API::JSONDownloadStrategy Private

Inherits:
AbstractDownloadStrategy show all
Defined in:
api/json_download.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cache, #url

Instance Method Summary collapse

Methods inherited from AbstractDownloadStrategy

#basename, #clear_cache, #quiet!, #quiet?, #source_modified_time, #stage

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods included from Context

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

Constructor Details

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

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



10
11
12
13
14
# File 'api/json_download.rb', line 10

def initialize(url, name, version, **meta)
  super
  @target = T.let(meta.fetch(:target), Pathname)
  @stale_seconds = T.let(meta.fetch(:stale_seconds), Integer)
end

Instance Method Details

#cached_locationPathname

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



25
26
27
# File 'api/json_download.rb', line 25

def cached_location
  meta.fetch(:target)
end

#fetch(timeout: nil) ⇒ Pathname

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • timeout (Integer, Float, nil) (defaults to: nil)

Returns:



17
18
19
20
21
22
# File 'api/json_download.rb', line 17

def fetch(timeout: nil)
  with_context quiet: quiet? do
    Homebrew::API.fetch_json_api_file(url, target: cached_location, stale_seconds: meta.fetch(:stale_seconds))
  end
  cached_location
end