Implement PR feedback

This commit is contained in:
Ben Muschol 2017-08-14 11:08:56 -04:00
parent 24da1ecd3d
commit 603bdd01a8
4 changed files with 6 additions and 6 deletions

View File

@ -17,7 +17,7 @@ module Hbc
def self.search_remote(query)
matches = GitHub.search_code(user: "caskroom", path: "Casks",
filename: query, extension: "rb")
Array(matches).map do |match|
matches.map do |match|
tap = Tap.fetch(match["repository"]["full_name"])
next if tap.installed?
"#{tap.name}/#{File.basename(match["path"], ".rb")}"

View File

@ -104,7 +104,7 @@ module Homebrew
valid_dirnames = ["Formula", "HomebrewFormula", "Casks", "."].freeze
matches = GitHub.search_code(user: ["Homebrew", "caskroom"], filename: query, extension: "rb")
Array(matches).map do |match|
matches.map do |match|
dirname, filename = File.split(match["path"])
next unless valid_dirnames.include?(dirname)
tap = Tap.fetch(match["repository"]["full_name"])

View File

@ -14,8 +14,8 @@ describe GitHub do
describe "::query_string" do
it "builds a query with the given hash parameters formatted as key:value" do
query = subject.query_string(user: "Homebrew", repo: "Brew")
expect(query).to eq("q=user%3AHomebrew+repo%3ABrew&per_page=100")
query = subject.query_string(user: "Homebrew", repo: "brew")
expect(query).to eq("q=user%3AHomebrew+repo%3Abrew&per_page=100")
end
it "adds a variable number of top-level string parameters to the query when provided" do

View File

@ -296,12 +296,12 @@ module GitHub
end
def url_to(*subroutes)
URI.parse(File.join(API_URL, *subroutes))
URI.parse([API_URL, *subroutes].join("/"))
end
def search(entity, *queries, **qualifiers)
uri = url_to "search", entity
uri.query = query_string(*queries, **qualifiers)
open(uri) { |json| json["items"] }
open(uri) { |json| Array(json["items"]) }
end
end