From 54d18cee17a7af49b5858dd752bf2eda59014472 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sun, 20 Nov 2016 12:43:13 -0500 Subject: [PATCH] compat: deprecate Utils::JSON in favor of corelib JSON. --- Library/Homebrew/compat.rb | 1 + Library/Homebrew/{utils => compat}/json.rb | 5 ++++- Library/Homebrew/utils.rb | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) rename Library/Homebrew/{utils => compat}/json.rb (77%) diff --git a/Library/Homebrew/compat.rb b/Library/Homebrew/compat.rb index db0ece584a..0b81e037ab 100644 --- a/Library/Homebrew/compat.rb +++ b/Library/Homebrew/compat.rb @@ -18,3 +18,4 @@ require "compat/language/haskell" require "compat/xcode" require "compat/software_spec" require "compat/utils" +require "compat/json" diff --git a/Library/Homebrew/utils/json.rb b/Library/Homebrew/compat/json.rb similarity index 77% rename from Library/Homebrew/utils/json.rb rename to Library/Homebrew/compat/json.rb index 21c5b52b0a..c8bf1c292a 100644 --- a/Library/Homebrew/utils/json.rb +++ b/Library/Homebrew/compat/json.rb @@ -7,16 +7,19 @@ module Utils Error = Class.new(StandardError) def load(str) - ::JSON.load(str) + odeprecated "Utils::JSON.load", "JSON.parse" + ::JSON.parse(str) rescue ::JSON::ParserError => e raise Error, e.message end def dump(obj) + odeprecated "Utils::JSON.dump", "JSON.generate" ::JSON.generate(obj) end def stringify_keys(obj) + odeprecated "Utils::JSON.stringify_keys" case obj when Array obj.map { |val| stringify_keys(val) } diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 7a7673d017..89a90bed2d 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -9,7 +9,6 @@ require "utils/git" require "utils/github" require "utils/hash" require "utils/inreplace" -require "utils/json" require "utils/popen" require "utils/tty"