mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-16 22:06:43 -06:00
and corresponding testing_env.rb. * recast HOMEBREW_BREW_FILE as Hbc.homebrew_executable, defined in Hbc::Locations * recast HOMEBREW_REPOSITORY as Hbc.homebrew_repository * recast HOMEBREW_PREFIX as Hbc.homebrew_prefix * remove HOMEBREW_LIBRARY * recast existing Hbc.tapspath as Hbc.homebrew_tapspath to match new methods fixes #8705
35 lines
1 KiB
Ruby
35 lines
1 KiB
Ruby
class Hbc::Source::Tapped
|
|
def self.me?(query)
|
|
path_for_query(query).exist?
|
|
end
|
|
|
|
def self.path_for_query(query)
|
|
# Repeating Hbc.all_tokens is very slow for operations such as
|
|
# brew cask list, but memoizing the value might cause breakage
|
|
# elsewhere, given that installation and tap status is permitted
|
|
# to change during the course of an invocation.
|
|
token_with_tap = Hbc.all_tokens.find { |t| t.split('/').last == query.sub(/\.rb$/i,'') }
|
|
if token_with_tap
|
|
user, repo, token = token_with_tap.split('/')
|
|
Hbc.homebrew_tapspath.join(user, repo, 'Casks', "#{token}.rb")
|
|
else
|
|
Hbc.homebrew_tapspath.join(Hbc.default_tap, 'Casks', "#{query.sub(/\.rb$/i,'')}.rb")
|
|
end
|
|
end
|
|
|
|
attr_reader :token
|
|
|
|
def initialize(token)
|
|
@token = token
|
|
end
|
|
|
|
def load
|
|
path = self.class.path_for_query(token)
|
|
Hbc::Source::PathSlashOptional.new(path).load
|
|
end
|
|
|
|
def to_s
|
|
# stringify to fully-resolved location
|
|
self.class.path_for_query(token).expand_path.to_s
|
|
end
|
|
end
|