Drop unnecessary map + compact in search_tap

This commit is contained in:
Jack Nagel 2014-02-08 17:53:00 -05:00
parent 0b0d171566
commit d01c671d74

View File

@ -104,9 +104,13 @@ module Homebrew extend self
results = [] results = []
GitHub.open "https://api.github.com/repos/#{user}/homebrew-#{repo}/git/trees/HEAD?recursive=1" do |json| 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 user = user.downcase if user == "Homebrew" # special handling for the Homebrew organization
json["tree"].map{ |hash| hash['path'] }.compact.each do |file| json["tree"].each do |object|
name = File.basename(file, '.rb') next unless object["type"] == "blob"
if file =~ /\.rb$/ and name =~ rx
path = object["path"]
name = File.basename(path, ".rb")
if path.end_with?(".rb") && rx === name
results << "#{user}/#{repo}/#{name}" results << "#{user}/#{repo}/#{name}"
end end
end end