From ac10b2ab50e987858b9fa5514785b12b7600787f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 18 Mar 2017 16:56:59 +0200 Subject: [PATCH] Tap: add from_path helper method. This makes it easier to turn an arbitrary path into a tap path. --- Library/Homebrew/tap.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index ba55e3cf66..99138330b2 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -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