diff options
| author | Jack Nagel | 2013-06-22 22:46:39 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-06-22 22:46:49 -0500 |
| commit | 5439813c2712ab02191dfeb77df589d2a001e93b (patch) | |
| tree | 6335e83527bfb8385e84bd7892f1ff99d7282fff /Library/Homebrew/utils.rb | |
| parent | 863e1a3cc54a7a3fe0b049d5754b235bd4208d3f (diff) | |
| download | brew-5439813c2712ab02191dfeb77df589d2a001e93b.tar.bz2 | |
Extract method in Github module
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 49c81598e..89542fe8e 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -271,6 +271,11 @@ module GitHub extend self end end + def each_issue_matching(query, &block) + uri = URI.parse("https://api.github.com/legacy/issues/search/mxcl/homebrew/open/#{query}") + open(uri) { |f| Utils::JSON.load(f.read)['issues'].each(&block) } + end + def issues_for_formula name # bit basic as depends on the issue at github having the exact name of the # formula in it. Which for stuff like objective-caml is unlikely. So we @@ -280,13 +285,9 @@ module GitHub extend self issues = [] - uri = URI.parse("https://api.github.com/legacy/issues/search/mxcl/homebrew/open/#{name}") - - GitHub.open uri do |f| - Utils::JSON.load(f.read)['issues'].each do |issue| - # don't include issues that just refer to the tool in their body - issues << issue['html_url'] if issue['title'].include? name - end + each_issue_matching(name) do |issue| + # don't include issues that just refer to the tool in their body + issues << issue['html_url'] if issue['title'].include? name end issues @@ -294,11 +295,10 @@ module GitHub extend self def find_pull_requests rx query = rx.source.delete('.*').gsub('\\', '') - uri = URI.parse("https://api.github.com/legacy/issues/search/mxcl/homebrew/open/#{query}") - GitHub.open uri do |f| - Utils::JSON.load(f.read)['issues'].each do |pull| - yield pull['pull_request_url'] if rx.match pull['title'] and pull['pull_request_url'] + each_issue_matching(query) do |issue| + if rx === issue['title'] && issue.has_key?('pull_request_url') + yield issue['pull_request_url'] end end end |
