diff options
| author | Mike McQuaid | 2017-03-18 16:56:59 +0200 |
|---|---|---|
| committer | Mike McQuaid | 2017-03-20 18:20:31 +0200 |
| commit | ac10b2ab50e987858b9fa5514785b12b7600787f (patch) | |
| tree | 3759f17e6618bd359971795997c42a5c60c97333 /Library | |
| parent | 1c10a6260fb4f4036d68b4c34acc6135b26b93d6 (diff) | |
| download | brew-ac10b2ab50e987858b9fa5514785b12b7600787f.tar.bz2 | |
Tap: add from_path helper method.
This makes it easier to turn an arbitrary path into a tap path.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/tap.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index ba55e3cf6..99138330b 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 |
