aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-06-12 14:48:16 -0500
committerJack Nagel2013-06-12 14:48:16 -0500
commitbceae883c7ca5785cb67aea21d8fabf2e9a309e3 (patch)
treedc214f6fc8fbbd97784be333132446a500af390c /Library
parentc77e9d5cdffd557be9194ac38274f2a1a712ddc0 (diff)
downloadhomebrew-bceae883c7ca5785cb67aea21d8fabf2e9a309e3.tar.bz2
Extract query construction
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/search.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 538a00ddc..85022888b 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -13,13 +13,7 @@ module Homebrew extend self
exec_browser "http://packages.debian.org/search?keywords=#{ARGV.next}&searchon=names&suite=all&section=all"
else
query = ARGV.first
- rx = case query
- when nil then ""
- when %r{^/(.*)/$} then Regexp.new($1)
- else
- /.*#{Regexp.escape query}.*/i
- end
-
+ rx = query_regexp(query)
search_results = search_brews rx
puts_columns search_results
@@ -61,6 +55,14 @@ module Homebrew extend self
end
end
+ def query_regexp(query)
+ case query
+ when nil then ""
+ when %r{^/(.*)/$} then Regexp.new($1)
+ else /.*#{Regexp.escape(query)}.*/i
+ end
+ end
+
def search_tap user, repo, rx
return [] if (HOMEBREW_LIBRARY/"Taps/#{user.downcase}-#{repo.downcase}").directory?