From 4ff62bd42f189d8a9df97096fb43f72a9cac837b Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 8 Feb 2014 17:53:00 -0500 Subject: Drop unnecessary map + compact in search_tap --- Library/Homebrew/cmd/search.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 71e1d1720..e7eb26377 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -104,9 +104,13 @@ module Homebrew extend self results = [] GitHub.open "https://api.github.com/repos/#{user}/homebrew-#{repo}/git/trees/HEAD?recursive=1" do |json| user = user.downcase if user == "Homebrew" # special handling for the Homebrew organization - json["tree"].map{ |hash| hash['path'] }.compact.each do |file| - name = File.basename(file, '.rb') - if file =~ /\.rb$/ and name =~ rx + json["tree"].each do |object| + next unless object["type"] == "blob" + + path = object["path"] + name = File.basename(path, ".rb") + + if path.end_with?(".rb") && rx === name results << "#{user}/#{repo}/#{name}" end end -- cgit v1.2.3