aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils/github.rb
diff options
context:
space:
mode:
authorMike McQuaid2016-11-21 18:45:20 +0000
committerGitHub2016-11-21 18:45:20 +0000
commitc3f959d6af36f075600aac63f208d59c30cd602c (patch)
tree336233a927c2be8b69f74dd704b73b3293d6ac33 /Library/Homebrew/utils/github.rb
parentc7267b123d38d1c96c2ca786c942255d2417cd86 (diff)
parentd07b9ed7f2e8806b1840b4f60605ef45487655e1 (diff)
downloadbrew-c3f959d6af36f075600aac63f208d59c30cd602c.tar.bz2
Merge pull request #1542 from woodruffw/deprecate-utils-json
compat: deprecate Utils::JSON in favor of corelib JSON.
Diffstat (limited to 'Library/Homebrew/utils/github.rb')
-rw-r--r--Library/Homebrew/utils/github.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb
index 43a0e88a8..5f961974c 100644
--- a/Library/Homebrew/utils/github.rb
+++ b/Library/Homebrew/utils/github.rb
@@ -149,9 +149,9 @@ module GitHub
data_tmpfile = nil
if data
begin
- data = Utils::JSON.dump data
+ data = JSON.generate data
data_tmpfile = Tempfile.new("github_api_post", HOMEBREW_TEMP)
- rescue Utils::JSON::Error => e
+ rescue JSON::ParserError => e
raise Error, "Failed to parse JSON request:\n#{e.message}\n#{data}", e.backtrace
end
end
@@ -183,13 +183,13 @@ module GitHub
if !http_code.start_with?("2") && !status.success?
raise_api_error(output, errors, http_code, headers, scopes)
end
- json = Utils::JSON.load output
+ json = JSON.parse output
if block_given?
yield json
else
json
end
- rescue Utils::JSON::Error => e
+ rescue JSON::ParserError => e
raise Error, "Failed to parse JSON response\n#{e.message}", e.backtrace
end
end
@@ -205,7 +205,7 @@ module GitHub
if meta.fetch("x-ratelimit-remaining", 1).to_i <= 0
reset = meta.fetch("x-ratelimit-reset").to_i
- error = Utils::JSON.load(output)["message"]
+ error = JSON.parse(output)["message"]
raise RateLimitExceededError.new(reset, error)
end
@@ -218,7 +218,7 @@ module GitHub
raise HTTPNotFoundError, output
else
error = begin
- Utils::JSON.load(output)["message"]
+ JSON.parse(output)["message"]
rescue
nil
end