Skip to content
Snippets Groups Projects
Commit ac10b2ab authored by Mike McQuaid's avatar Mike McQuaid
Browse files

Tap: add from_path helper method.

This makes it easier to turn an arbitrary path into a tap path.
parent 1c10a626
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,15 @@ class Tap ...@@ -41,6 +41,15 @@ class Tap
CACHE.fetch(cache_key) { |key| CACHE[key] = Tap.new(user, repo) } CACHE.fetch(cache_key) { |key| CACHE[key] = Tap.new(user, repo) }
end 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 extend Enumerable
# The user name of this {Tap}. Usually, it's the Github username of # The user name of this {Tap}. Usually, it's the Github username of
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment