mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Tap: add from_path helper method.
This makes it easier to turn an arbitrary path into a tap path.
This commit is contained in:
parent
1c10a6260f
commit
ac10b2ab50
@ -41,6 +41,15 @@ class Tap
|
||||
CACHE.fetch(cache_key) { |key| CACHE[key] = Tap.new(user, repo) }
|
||||
end
|
||||
|
||||
def self.from_path(path)
|
||||
path.to_s =~ HOMEBREW_TAP_PATH_REGEX
|
||||
raise "Invalid tap path '#{path}'" unless $1
|
||||
fetch($1, $2)
|
||||
rescue
|
||||
# No need to error as a nil tap is sufficient to show failure.
|
||||
nil
|
||||
end
|
||||
|
||||
extend Enumerable
|
||||
|
||||
# The user name of this {Tap}. Usually, it's the Github username of
|
||||
|
Loading…
x
Reference in New Issue
Block a user