lib/xing/specdoc/document.rb in xing-backend-specdoc-0.0.1 vs lib/xing/specdoc/document.rb in xing-backend-specdoc-0.0.2
- old
+ new
@@ -8,14 +8,24 @@
@contents = contents
end
attr_reader :path, :contents
def parsed_body
- @parsed_body ||= JSON.parse(contents)
+ @parsed_body ||=
+ if contents.empty?
+ {}
+ else
+ JSON.parse(contents)
+ end
end
def pretty_body
- @pretty_body ||= JSON.pretty_generate(parsed_body)+"\n"
+ @pretty_body ||=
+ if contents.empty?
+ ""
+ else
+ JSON.pretty_generate(parsed_body)+"\n"
+ end
end
def difference_from(other)
diff(parsed_body, other)
end