From d84b8cf2885b79854221ad5968d8ec03955a9969 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Thu, 17 Jun 2010 10:45:16 -0700 Subject: Extract search_brews method --- Library/Homebrew/brew.h.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index bd4153b16..24f51108f 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -399,6 +399,17 @@ def outdated_brews return results end +def search_brews text + require "formula" + formulae = Formulary.names with_aliases=true + if text =~ /^\/(.*)\/$/ + return formulae.grep(Regexp.new($1)) + else + search_term = Regexp.escape(text || "") + return formulae.grep(/.*#{search_term}.*/) + end +end + ########################################################## class PrettyListing class PrettyListing def initialize path -- cgit v1.2.3