aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorWilliam Woodruff2016-11-20 13:00:01 -0500
committerWilliam Woodruff2016-11-20 20:06:25 -0500
commitd07b9ed7f2e8806b1840b4f60605ef45487655e1 (patch)
tree90387191e0debec6f578dc58646d7fb588f08333 /Library
parent54d18cee17a7af49b5858dd752bf2eda59014472 (diff)
downloadbrew-d07b9ed7f2e8806b1840b4f60605ef45487655e1.tar.bz2
Replace Utils::JSON with corelib JSON calls.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/info.rb4
-rw-r--r--Library/Homebrew/cmd/outdated.rb2
-rw-r--r--Library/Homebrew/cmd/style.rb4
-rw-r--r--Library/Homebrew/cmd/tap-info.rb2
-rw-r--r--Library/Homebrew/descriptions.rb4
-rw-r--r--Library/Homebrew/dev-cmd/boneyard-formula-pr.rb4
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb4
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb4
-rw-r--r--Library/Homebrew/download_strategy.rb6
-rw-r--r--Library/Homebrew/tab.rb6
-rw-r--r--Library/Homebrew/tap.rb8
-rw-r--r--Library/Homebrew/test/json_test.rb8
-rw-r--r--Library/Homebrew/test/support/helper/integration_command_test_case.rb2
-rw-r--r--Library/Homebrew/test/tab_test.rb2
-rw-r--r--Library/Homebrew/utils/github.rb12
15 files changed, 36 insertions, 36 deletions
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index a3062ec99..fc47e1731 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -22,7 +22,7 @@ require "options"
require "formula"
require "keg"
require "tab"
-require "utils/json"
+require "json"
module Homebrew
module_function
@@ -72,7 +72,7 @@ module Homebrew
ARGV.formulae
end
json = ff.map(&:to_hash)
- puts Utils::JSON.dump(json)
+ puts JSON.generate(json)
end
def github_remote_path(remote, path)
diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb
index 3ff3ef107..9ed7a0f79 100644
--- a/Library/Homebrew/cmd/outdated.rb
+++ b/Library/Homebrew/cmd/outdated.rb
@@ -88,7 +88,7 @@ module Homebrew
installed_versions: outdated_versions.collect(&:to_s),
current_version: current_version }
end
- puts Utils::JSON.dump(json)
+ puts JSON.generate(json)
outdated
end
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb
index 8b6793e77..9befcf9ac 100644
--- a/Library/Homebrew/cmd/style.rb
+++ b/Library/Homebrew/cmd/style.rb
@@ -14,7 +14,7 @@
#: Exits with a non-zero status if any style violations are found.
require "utils"
-require "utils/json"
+require "json"
module Homebrew
module_function
@@ -74,7 +74,7 @@ module Homebrew
# exitstatus can also be nil if RuboCop process crashes, e.g. due to
# native extension problems
raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1
- RubocopResults.new(Utils::JSON.load(json))
+ RubocopResults.new(JSON.parse(json))
else
raise "Invalid output_type for check_style_impl: #{output_type}"
end
diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb
index f31bf480c..0d9f8db3d 100644
--- a/Library/Homebrew/cmd/tap-info.rb
+++ b/Library/Homebrew/cmd/tap-info.rb
@@ -82,6 +82,6 @@ module Homebrew
end
def print_tap_json(taps)
- puts Utils::JSON.dump(taps.map(&:to_hash))
+ puts JSON.generate(taps.map(&:to_hash))
end
end
diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb
index 08860f7cf..a338bb73a 100644
--- a/Library/Homebrew/descriptions.rb
+++ b/Library/Homebrew/descriptions.rb
@@ -12,14 +12,14 @@ class Descriptions
# If the cache file exists, load it into, and return, a hash; otherwise,
# return nil.
def self.load_cache
- @cache = Utils::JSON.load(CACHE_FILE.read) if CACHE_FILE.exist?
+ @cache = JSON.parse(CACHE_FILE.read) if CACHE_FILE.exist?
end
# Write the cache to disk after ensuring the existence of the containing
# directory.
def self.save_cache
HOMEBREW_CACHE.mkpath
- CACHE_FILE.atomic_write Utils::JSON.dump(@cache)
+ CACHE_FILE.atomic_write JSON.dump(@cache)
end
# Create a hash mapping all formulae to their descriptions;
diff --git a/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb b/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
index 3d95f14b9..4c2fbb6f3 100644
--- a/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
@@ -9,7 +9,7 @@
#: If `--reason=<reason>` is passed, append this to the commit/PR message.
require "formula"
-require "utils/json"
+require "json"
require "fileutils"
begin
@@ -60,7 +60,7 @@ module Homebrew
EOS
safe_system "git", "add", tap_migrations_path
end
- tap_migrations = Utils::JSON.load(File.read(tap_migrations_path))
+ tap_migrations = JSON.parse(File.read(tap_migrations_path))
tap_migrations[formula.name] = boneyard_tap.name
tap_migrations = tap_migrations.sort.inject({}) { |acc, elem| acc.merge!(elem[0] => elem[1]) }
tap_migrations_path.atomic_write(JSON.pretty_generate(tap_migrations) + "\n")
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 7e98f2ebb..9618cf412 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -344,7 +344,7 @@ module Homebrew
},
}
File.open("#{filename.prefix}.bottle.json", "w") do |file|
- file.write Utils::JSON.dump json
+ file.write JSON.generate json
end
end
@@ -352,7 +352,7 @@ module Homebrew
write = ARGV.include? "--write"
bottles_hash = ARGV.named.reduce({}) do |hash, json_file|
- deep_merge_hashes hash, Utils::JSON.load(IO.read(json_file))
+ deep_merge_hashes hash, JSON.parse(IO.read(json_file))
end
bottles_hash.each do |formula_name, bottle_hash|
diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index 7e6e86a85..f7006baaa 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -32,7 +32,7 @@
require "net/http"
require "net/https"
require "utils"
-require "utils/json"
+require "json"
require "formula"
require "formulary"
require "tap"
@@ -433,7 +433,7 @@ module Homebrew
return nil unless $?.success?
Homebrew.force_utf8!(json)
- FormulaInfoFromJson.new(Utils::JSON.load(json)[0])
+ FormulaInfoFromJson.new(JSON.parse(json)[0])
end
def bottle_tags
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 63b821ceb..1f77fa20c 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -1,4 +1,4 @@
-require "utils/json"
+require "json"
require "rexml/document"
require "time"
@@ -444,14 +444,14 @@ class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
return super if @tried_apache_mirror
@tried_apache_mirror = true
- mirrors = Utils::JSON.load(apache_mirrors)
+ mirrors = JSON.parse(apache_mirrors)
path_info = mirrors.fetch("path_info")
@url = mirrors.fetch("preferred") + path_info
@mirrors |= %W[https://archive.apache.org/dist/#{path_info}]
ohai "Best Mirror #{@url}"
super
- rescue IndexError, Utils::JSON::Error
+ rescue IndexError, JSON::ParserError
raise CurlDownloadStrategyError, "Couldn't determine mirror, try again later."
end
end
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 3bb7d8b62..28f29aaad 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -1,7 +1,7 @@
require "cxxstdlib"
require "ostruct"
require "options"
-require "utils/json"
+require "json"
require "development_tools"
# Inherit from OpenStruct to gain a generic initialization method that takes a
@@ -58,7 +58,7 @@ class Tab < OpenStruct
# Like Tab.from_file, but bypass the cache.
def self.from_file_content(content, path)
- attributes = Utils::JSON.load(content)
+ attributes = JSON.parse(content)
attributes["tabfile"] = path
attributes["source_modified_time"] ||= 0
attributes["source"] ||= {}
@@ -313,7 +313,7 @@ class Tab < OpenStruct
"source" => source,
}
- Utils::JSON.dump(attributes)
+ JSON.generate(attributes)
end
def write
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index 3659abe4f..68b21ac60 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -442,10 +442,10 @@ class Tap
# Hash with tap formula renames
def formula_renames
- require "utils/json"
+ require "json"
@formula_renames ||= if (rename_file = path/"formula_renames.json").file?
- Utils::JSON.load(rename_file.read)
+ JSON.parse(rename_file.read)
else
{}
end
@@ -453,10 +453,10 @@ class Tap
# Hash with tap migrations
def tap_migrations
- require "utils/json"
+ require "json"
@tap_migrations ||= if (migration_file = path/"tap_migrations.json").file?
- Utils::JSON.load(migration_file.read)
+ JSON.parse(migration_file.read)
else
{}
end
diff --git a/Library/Homebrew/test/json_test.rb b/Library/Homebrew/test/json_test.rb
index 14d2f2b4c..7c4c3671d 100644
--- a/Library/Homebrew/test/json_test.rb
+++ b/Library/Homebrew/test/json_test.rb
@@ -1,20 +1,20 @@
require "testing_env"
-require "utils/json"
+require "json"
class JsonSmokeTest < Homebrew::TestCase
def test_encode
hash = { "foo" => ["bar", "baz"] }
json = '{"foo":["bar","baz"]}'
- assert_equal json, Utils::JSON.dump(hash)
+ assert_equal json, JSON.generate(hash)
end
def test_decode
hash = { "foo" => ["bar", "baz"], "qux" => 1 }
json = '{"foo":["bar","baz"],"qux":1}'
- assert_equal hash, Utils::JSON.load(json)
+ assert_equal hash, JSON.parse(json)
end
def test_decode_failure
- assert_raises(Utils::JSON::Error) { Utils::JSON.load("nope") }
+ assert_raises(JSON::ParserError) { JSON.parse("nope") }
end
end
diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb
index 5940fd84b..b79fdd6e0 100644
--- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb
+++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb
@@ -185,7 +185,7 @@ class IntegrationCommandTestCase < Homebrew::TestCase
cmd("install", old_name)
(core_tap.path/"Formula/#{old_name}.rb").unlink
formula_renames = core_tap.path/"formula_renames.json"
- formula_renames.write Utils::JSON.dump(old_name => new_name)
+ formula_renames.write JSON.generate(old_name => new_name)
core_tap.path.cd do
shutup do
diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb
index 76c9aacc9..ef653103c 100644
--- a/Library/Homebrew/test/tab_test.rb
+++ b/Library/Homebrew/test/tab_test.rb
@@ -186,7 +186,7 @@ class TabTests < Homebrew::TestCase
end
def test_to_json
- tab = Tab.new(Utils::JSON.load(@tab.to_json))
+ tab = Tab.new(JSON.parse(@tab.to_json))
assert_equal @tab.used_options.sort, tab.used_options.sort
assert_equal @tab.unused_options.sort, tab.unused_options.sort
assert_equal @tab.built_as_bottle, tab.built_as_bottle
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