Class: Cask::CaskLoader::FromInstalledPathLoader Private

Inherits:
FromPathLoader show all
Defined in:
cask/cask_loader.rb

Overview

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.

Loader which loads a cask from the installed cask file.

Instance Attribute Summary

Attributes inherited from FromPathLoader

#path, #token

Attributes inherited from AbstractContentLoader

#content, #tap

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FromPathLoader

#load

Methods included from ILoader

#load

Constructor Details

#initialize(path, token: "") ⇒ 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:



520
521
522
523
524
525
# File 'cask/cask_loader.rb', line 520

def initialize(path, token: "")
  super

  installed_tap = Cask.new(@token).tab.tap
  @tap = installed_tap if installed_tap
end

Class Method Details

.try_new(ref, warn: false) ⇒ T.attached_class?

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:

Returns:

  • (T.attached_class, nil)


505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'cask/cask_loader.rb', line 505

def self.try_new(ref, warn: false)
  token = if ref.is_a?(String)
    ref
  elsif ref.is_a?(Pathname)
    ref.basename(ref.extname).to_s
  end
  return unless token

  possible_installed_cask = Cask.new(token)
  return unless (installed_caskfile = possible_installed_cask.installed_caskfile)

  new(installed_caskfile)
end