aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils
diff options
context:
space:
mode:
authorJack Nagel2013-06-22 16:51:08 -0500
committerJack Nagel2013-06-22 21:34:02 -0500
commit163067512bb15e0582ad9d59555697126b9aeac6 (patch)
treef0128fb96018751be17281a59161fe3b72e8ad56 /Library/Homebrew/utils
parente3f061d9900187e0082f17d4e857a55ff8fc4874 (diff)
downloadhomebrew-163067512bb15e0582ad9d59555697126b9aeac6.tar.bz2
Add Utils::JSON to wrap the JSON implementation
Diffstat (limited to 'Library/Homebrew/utils')
-rw-r--r--Library/Homebrew/utils/json.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/utils/json.rb b/Library/Homebrew/utils/json.rb
new file mode 100644
index 000000000..f52881c84
--- /dev/null
+++ b/Library/Homebrew/utils/json.rb
@@ -0,0 +1,21 @@
+require 'vendor/multi_json'
+
+module Utils
+ module JSON
+ extend self
+
+ Error = Class.new(StandardError)
+
+ def load(str)
+ MultiJson.load(str)
+ rescue MultiJson::DecodeError => e
+ raise Error, e.message
+ end
+
+ def dump(obj)
+ MultiJson.dump(obj)
+ rescue MultiJson::EncodeError => e
+ raise Error, e.message
+ end
+ end
+end