aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils/github.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-04-25 12:50:23 +0200
committerGitHub2017-04-25 12:50:23 +0200
commit24a339ee239a4e13e5162085780687fcd2b7bc9f (patch)
tree4a53d351a1135b10032b73c129c29c68c2a3a3f6 /Library/Homebrew/utils/github.rb
parenta38133e5a116ac3e08a856e38ce76dc5453a963f (diff)
parent133e5ddf6ad1b7c931f4686922ba4d61ea450f3a (diff)
downloadbrew-24a339ee239a4e13e5162085780687fcd2b7bc9f.tar.bz2
Merge pull request #2541 from reitermarkus/cask-search
Add remote search to `brew cask search`.
Diffstat (limited to 'Library/Homebrew/utils/github.rb')
-rw-r--r--Library/Homebrew/utils/github.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb
index a5ed5394a..88c5199c2 100644
--- a/Library/Homebrew/utils/github.rb
+++ b/Library/Homebrew/utils/github.rb
@@ -4,7 +4,7 @@ require "tempfile"
module GitHub
module_function
- ISSUES_URI = URI.parse("https://api.github.com/search/issues")
+ API_URL = "https://api.github.com".freeze
CREATE_GIST_SCOPES = ["gist"].freeze
CREATE_ISSUE_SCOPES = ["public_repo"].freeze
@@ -228,13 +228,19 @@ module GitHub
end
def issues_matching(query, qualifiers = {})
- uri = ISSUES_URI.dup
+ uri = URI.parse("#{API_URL}/search/issues")
uri.query = build_query_string(query, qualifiers)
open(uri) { |json| json["items"] }
end
def repository(user, repo)
- open(URI.parse("https://api.github.com/repos/#{user}/#{repo}")) { |j| j }
+ open(URI.parse("#{API_URL}/repos/#{user}/#{repo}"))
+ end
+
+ def search_code(*params)
+ uri = URI.parse("#{API_URL}/search/code")
+ uri.query = "q=#{uri_escape(params.join(" "))}"
+ open(uri) { |json| json["items"] }
end
def build_query_string(query, qualifiers)
@@ -286,7 +292,7 @@ module GitHub
end
def private_repo?(user, repo)
- uri = URI.parse("https://api.github.com/repos/#{user}/#{repo}")
+ uri = URI.parse("#{API_URL}/repos/#{user}/#{repo}")
open(uri) { |json| json["private"] }
end
end