Class: Cask::CaskLoader::FromNameLoader Private

Inherits:
FromTapLoader 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 tries loading casks from tap paths, failing if the same token exists in multiple taps.

Instance Attribute Summary

Attributes inherited from FromTapLoader

#tap

Attributes inherited from FromPathLoader

#path, #token

Attributes inherited from AbstractContentLoader

#content, #tap

Class Method Summary collapse

Methods inherited from FromTapLoader

#initialize, #load

Methods inherited from FromPathLoader

#initialize, #load

Methods included from ILoader

#load

Constructor Details

This class inherits a constructor from Cask::CaskLoader::FromTapLoader

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)


466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'cask/cask_loader.rb', line 466

def self.try_new(ref, warn: false)
  return unless ref.is_a?(String)
  return if ref.include?("/")

  token = ref

  loaders = Tap.filter_map { |tap| super("#{tap}/#{token}", warn: warn) }
               .select { _1.path.exist? }

  case loaders.count
  when 1
    loaders.first
  when 2..Float::INFINITY
    raise TapCaskAmbiguityError.new(token, loaders)
  end
end