diff options
| author | Misty De Meo | 2012-01-12 21:10:03 -0600 |
|---|---|---|
| committer | Misty De Meo | 2012-01-13 22:31:55 -0600 |
| commit | f2f26a11bb4a4f96846a1d8ac75d73509e33c14d (patch) | |
| tree | 171c943873ebc9d5b4228962ae0ae428dc7677b9 | |
| parent | 14d7d03425a80fd226cb7e7584e840fbf18bd499 (diff) | |
| download | homebrew-f2f26a11bb4a4f96846a1d8ac75d73509e33c14d.tar.bz2 | |
search: return results while parsing
Instead of returning a full list of results after parsing, yield and
print each result as it's found for a snappier user experience.
Closes #9576.
Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
| -rw-r--r-- | Library/Homebrew/cmd/search.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index a51367e18..50ed36b3d 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -29,10 +29,8 @@ module Homebrew extend self end if search_results.empty? and not blacklisted? query - pulls = GitHub.find_pull_requests rx - unless pulls.empty? - puts "Open pull requests matching \"#{query}\":", *pulls.map { |p| " #{p}" } - end + puts "No formula found for \"#{query}\". Searching open pull requests..." + GitHub.find_pull_requests(rx) { |pull| puts pull } end end end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 644023a0c..4de58cc36 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -432,17 +432,15 @@ module GitHub extend self require 'open-uri' require 'vendor/multi_json' - pulls = [] query = rx.source.delete '.*' uri = URI.parse("http://github.com/api/v2/json/issues/search/mxcl/homebrew/open/#{query}") open uri do |f| MultiJson.decode(f.read)["issues"].each do |pull| - pulls << pull['pull_request_url'] if rx.match pull['title'] and pull["pull_request_url"] + yield pull['pull_request_url'] if rx.match pull['title'] and pull["pull_request_url"] end end - pulls rescue - [] + nil end end |
