Merge pull request #14514 from apainintheneck/add-logging-to-cask-loader

Adds logging to cask loader
This commit is contained in:
Mike McQuaid 2023-02-06 15:20:50 +01:00 committed by GitHub
commit bdc22fe0c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,8 @@ module Cask
#
# @api private
module CaskLoader
extend Context
# Loads a cask from a string.
class FromContentLoader
attr_reader :content
@ -175,6 +177,17 @@ module Cask
end
end
# Loads a cask from the default tap path.
class FromDefaultTapPathLoader < FromTapPathLoader
def self.can_load?(ref)
super CaskLoader.default_path(ref)
end
def initialize(ref)
super CaskLoader.default_path(ref)
end
end
# Loads a cask from an existing {Cask} instance.
class FromInstanceLoader
def self.can_load?(ref)
@ -376,12 +389,14 @@ module Cask
FromTapLoader,
FromTapPathLoader,
FromPathLoader,
FromDefaultTapPathLoader,
].each do |loader_class|
return loader_class.new(ref) if loader_class.can_load?(ref)
if loader_class.can_load?(ref)
$stderr.puts "#{$PROGRAM_NAME} (#{loader_class}): loading #{ref}" if debug?
return loader_class.new(ref)
end
end
return FromTapPathLoader.new(default_path(ref)) if FromTapPathLoader.can_load?(default_path(ref))
case (possible_tap_casks = tap_paths(ref)).count
when 1
return FromTapPathLoader.new(possible_tap_casks.first)