From 5641e6b38e29da6bc00e92111a24d17edaf8f736 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 16 Mar 2012 22:37:11 +0000 Subject: `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.--- Library/Homebrew/cmd/search.rb | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'Library') 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 -- cgit v1.2.3