aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorMax Howell2012-03-16 22:37:11 +0000
committerMax Howell2012-03-16 22:37:11 +0000
commit5641e6b38e29da6bc00e92111a24d17edaf8f736 (patch)
tree2d52192f69de480a4d71dc45135c8ee3d6c70d7c /Library/Homebrew/cmd
parentd66e23ac4bf112aa891f30461b204b0f6f331b8e (diff)
downloadhomebrew-5641e6b38e29da6bc00e92111a24d17edaf8f736.tar.bz2
`brew search` will search taps we decide are core
This means `brew search` always does some network operations. Which is a shame, but I think (for brew) fine. Probably the no-connectivity handling needs to be improved.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/search.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 50ed36b3d..4b8226410 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -28,13 +28,38 @@ module Homebrew extend self
puts msg
end
- if search_results.empty? and not blacklisted? query
+ $found = search_results.length
+ puts_columns search_tap "adamv", "alt", rx
+ puts_columns search_tap "josegonzalez", "php", rx
+
+ if $found == 0 and not blacklisted? query
puts "No formula found for \"#{query}\". Searching open pull requests..."
GitHub.find_pull_requests(rx) { |pull| puts pull }
end
end
end
+ def search_tap user, repo, rx
+ return [] if (HOMEBREW_LIBRARY/"Taps/#{user}-#{repo}").directory?
+
+ require 'open-uri'
+ require 'yaml'
+
+ results = []
+ open "http://github.com/api/v2/yaml/blob/all/#{user}/homebrew-#{repo}/master" do |f|
+ YAML::load(f.read)["blobs"].each do |file, _|
+ name = File.basename(file, '.rb')
+ if file =~ /\.rb$/ and name =~ rx
+ results << "#{user}/#{repo}/#{name}"
+ $found += 1
+ end
+ end
+ end
+ results
+ rescue
+ []
+ end
+
def search_brews rx
if rx.to_s.empty?
Formula.names