Use "legacy" search API when completing tap names

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-04-30 15:32:07 -05:00
parent de5f0a8e9b
commit 644af3696b
2 changed files with 19 additions and 22 deletions

View File

@ -95,28 +95,7 @@ __brew_complete_tapped ()
__brew_complete_taps () __brew_complete_taps ()
{ {
if [[ -z "$__brew_cached_taps" ]]; then if [[ -z "$__brew_cached_taps" ]]; then
__brew_cached_taps="$(/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -e ' __brew_cached_taps="$(brew ls-taps)"
require "open-uri"
require "yaml"
begin
uri = URI.parse("http://github.com/api/v2/yaml/repos/search/homebrew")
open uri do |f|
YAML::load(f.read)["repositories"].each do |repo|
if repo[:name] =~ /^homebrew-(\w+)$/
puts tap = if repo[:username] == "Homebrew"
"homebrew/#{$1}"
else
repo[:username]+"/"+$1
end
end
end
end
rescue
nil
end
' 2>/dev/null)"
fi fi
__brewcomp "$__brew_cached_taps" __brewcomp "$__brew_cached_taps"

View File

@ -0,0 +1,18 @@
require 'open-uri'
require 'vendor/multi_json'
begin
open "https://api.github.com/legacy/repos/search/homebrew" do |f|
MultiJson.decode(f.read)["repositories"].each do |repo|
if repo['name'] =~ /^homebrew-(\S+)$/
puts tap = if repo['username'] == "Homebrew"
"homebrew/#{$1}"
else
repo['username']+"/"+$1
end
end
end
end
rescue
nil
end