From 6628d26b5bafe148c915cbdd2499e434680d578e Mon Sep 17 00:00:00 2001 From: Keith Gable Date: Sat, 22 Sep 2012 00:02:55 -0500 Subject: [PATCH] Make read_json_value handle "true" and "false" When I was attempting to push my docs back to CouchDB, I found that some of my design documents had certain properties serialized as literally "false" or "true". I don't necessarily disagree with that, but then the JSON parser complains. So this makes it return false or true when that's all in the file, which makes my docs import as expected. If there's a cleaner way to fix this, please let me know and I'll submit a better patch :) --- lib/couch_docs/design_directory.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/couch_docs/design_directory.rb b/lib/couch_docs/design_directory.rb index a39e445..f369b34 100644 --- a/lib/couch_docs/design_directory.rb +++ b/lib/couch_docs/design_directory.rb @@ -56,7 +56,14 @@ def expand_file(filename) end def read_json_value(filename) - JSON.parse(File.new(filename).read) + filedata = File.new(filename).read + if filedata == "false" + false + elsif filedata == "true" + true + else + JSON.parse(filedata) + end end def read_js_value(filename)