tolerate_json 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module TolerateJson
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/tolerate_json.rb CHANGED
@@ -19,7 +19,7 @@ module TolerateJson
19
19
 
20
20
  json = json.to_s.gsub(/\{[\s+]\"/, "{\"").gsub(/\{(\s+)\"/, "{\"").gsub(/\"(\s+)\}/, "\"}").gsub(/true(\s+)\}/, "true}").gsub(/false(\s+)\}/, "false}").gsub(/\",(\s+)\"/, '","')
21
21
 
22
- json = json.gsub("},", "},\n").gsub("],", "],\n").gsub("{[", "{\n[").gsub("}]", "}\n]").gsub("[{", "[\n{").gsub("]}", "]\n}").gsub("{\"", "{\n\"").gsub("\"}", "\"\n}").gsub("\",\"", "\",\n\"").gsub(":true,\"", ":true,\n\"").gsub(":false,\"", ":false,\n\"").gsub(":true}", ":true\n}").gsub(":false}", ":false\n}").gsub(/\:(\d+),\"/) { ":#{$1},\n\"" }.gsub(/\:(\d+),\"/,":\1,\n\"")
22
+ json = json.gsub("},", "},\n").gsub("],", "],\n").gsub("{[", "{\n[").gsub("}]", "}\n]").gsub("[{", "[\n{").gsub("]}", "]\n}").gsub("{\"", "{\n\"").gsub("\"}", "\"\n}").gsub("\",\"", "\",\n\"").gsub(":true,\"", ":true,\n\"").gsub(":false,\"", ":false,\n\"").gsub(":true}", ":true\n}").gsub(":false}", ":false\n}").gsub(/:(\d+)}/) { ":#{$1}\n}" }.gsub(/\:(\d+),\"/) { ":#{$1},\n\"" }.gsub(/\:(\d+),\"/,":\1,\n\"")
23
23
 
24
24
  output = []
25
25
 
@@ -52,6 +52,13 @@ describe TolerateJson do
52
52
  expect(t.pretty_print_json(unformatted)).to eq(formatted)
53
53
  end
54
54
 
55
+ it "should separate numbers and closing curly braces with cr" do
56
+ unformatted = '{"qux":{"foo":1}, "quux":"quuux"}'
57
+ formatted= "{\n \"qux\":{\n \"foo\":1\n },\n \"quux\":\"quuux\"\n}\n"
58
+
59
+ expect(t.pretty_print_json(unformatted)).to eq(formatted)
60
+ end
61
+
55
62
  it "should include only one cr at the end of the result" do
56
63
  unformatted = "{}\n\n\n"
57
64
  formatted= "{\n}\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tolerate_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: