diff_json 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 832e33f35765ba9f04a8ec8d627970746ebde044131b8c4ddfe3c36795c4ac76
4
- data.tar.gz: bd930e3ad8bce51daafd56d191301fbfb79bb9c052a6f3a0261b197c7e50db83
3
+ metadata.gz: cfe2f853f14295b632d6c9797e8d5fa6d033abdb4a2121882c89e89dea454b70
4
+ data.tar.gz: e20ffe297ef15903842062ff4678e9555a0c0b878c814e2457d877f1dec0ffb9
5
5
  SHA512:
6
- metadata.gz: 227514035adff84d7bec48bd57744b37082167262ea0603b53e98c9773127c4a1c28fb603fac0fdd6c9393391a9c9c212cf202c3994c7b79d31550808b7f61e1
7
- data.tar.gz: a4acea3ea16e5fe73d18717330f9992913c35959d4ac29a595b49d29fc62b51adcf3519b433a87812832b17859183ff1b9756e563898543df1986c5abe11cbc8
6
+ metadata.gz: 24c881ce5a6b3f08c2c3f4e83055abb897f3b1b0c895e2ccf98f97e184bfa18a4896aa9c167652a447bf17a909a166fc990e622432aa201c72e539d8007c2e9b
7
+ data.tar.gz: d9321212b669d051d7c60e2b8b105bc05c0f7a2cb4fccfcba1f00c7d7fe54724c1337c79e2183ace4a0888a5a4b46c351ddce79fb4b0443acc99e68ac7a44795
@@ -65,8 +65,7 @@ module DiffJson
65
65
  sub_diffs.each do |value, diff|
66
66
  diff[:old] = [] unless diff.key?(:old)
67
67
  diff[:new] = [] unless diff.key?(:new)
68
- diff[:old].delete_if{|line| line == [' ', '']}
69
- diff[:new].delete_if{|line| line == [' ', '']}
68
+
70
69
  diff[:old], diff[:new] = add_blank_lines(diff[:old], diff[:new])
71
70
  end
72
71
  end
@@ -263,11 +262,11 @@ module DiffJson
263
262
  new_item_lines.last[1] = "#{new_item_lines.last[1]}," if !last_loop and (new_item_lines.last[1].match(/[^\s]/))
264
263
  end
265
264
 
266
- old_item_lines, new_item_lines = add_blank_lines(old_item_lines, new_item_lines)
267
-
268
265
  add_object_sub_diff_if_required(item_path, old_item, old_item_lines) if old_item.is_a?(Hash) and old_operator == '-'
269
266
  add_object_sub_diff_if_required(item_path, new_item, new_item_lines, :new) if new_item.is_a?(Hash) and new_operator == '+'
270
267
 
268
+ old_item_lines, new_item_lines = add_blank_lines(old_item_lines, new_item_lines)
269
+
271
270
  old_array_lines += old_item_lines
272
271
  new_array_lines += new_item_lines
273
272
  end
@@ -57,23 +57,23 @@ module DiffJson
57
57
 
58
58
  (0..(lines[:old].length - 1)).each do |i|
59
59
  # Full, combined table output
60
- markup[:full] += "<tr class=\"diff-json-view-line\">\n"
61
- markup[:full] += "<td class=\"diff-json-view-line-operator\">#{lines[:old][i][0].gsub(/\s/, '&nbsp;')}</td>\n"
62
- markup[:full] += "<td class=\"diff-json-view-line-content #{content_highlight_class(:left, lines[:old][i][0])}\">#{lines[:old][i][1].gsub(/\s/, '&nbsp;')}</td>\n"
63
- markup[:full] += "<td class=\"diff-json-view-column-break\"></td>\n"
64
- markup[:full] += "<td class=\"diff-json-view-line-operator\">#{lines[:new][i][0].gsub(/\s/, '&nbsp;')}</td>\n"
65
- markup[:full] += "<td class=\"diff-json-view-line-content #{content_highlight_class(:right, lines[:new][i][0])}\">#{lines[:new][i][1].gsub(/\s/, '&nbsp;')}</td>\n"
66
- markup[:full] += "</tr>\n"
60
+ markup[:full] += " <tr class=\"diff-json-view-line\">\n"
61
+ markup[:full] += " <td class=\"diff-json-view-line-operator\"><pre>#{lines[:old][i][0]}</pre></td>\n"
62
+ markup[:full] += " <td class=\"diff-json-view-line-content #{content_highlight_class(:left, lines[:old][i][0])}\"><pre>#{lines[:old][i][1]}</pre></td>\n"
63
+ markup[:full] += " <td class=\"diff-json-view-column-break\"></td>\n"
64
+ markup[:full] += " <td class=\"diff-json-view-line-operator\"><pre>#{lines[:new][i][0]}</pre></td>\n"
65
+ markup[:full] += " <td class=\"diff-json-view-line-content #{content_highlight_class(:right, lines[:new][i][0])}\"><pre>#{lines[:new][i][1]}</pre></td>\n"
66
+ markup[:full] += " </tr>\n"
67
67
  # Split, left side output
68
- markup[:left] += "<tr class=\"diff-json-view-line\">\n"
69
- markup[:left] += "<td class=\"diff-json-view-line-operator\">#{lines[:old][i][0].gsub(/\s/, '&nbsp;')}</td>\n"
70
- markup[:left] += "<td class=\"diff-json-view-line-content #{content_highlight_class(:left, lines[:old][i][0])}\">#{lines[:old][i][1].gsub(/\s/, '&nbsp;')}</td>\n"
71
- markup[:left] += "</tr>\n"
68
+ markup[:left] += " <tr class=\"diff-json-view-line\">\n"
69
+ markup[:left] += " <td class=\"diff-json-view-line-operator\"><pre>#{lines[:old][i][0]}</pre></td>\n"
70
+ markup[:left] += " <td class=\"diff-json-view-line-content #{content_highlight_class(:left, lines[:old][i][0])}\"><pre>#{lines[:old][i][1]}</pre></td>\n"
71
+ markup[:left] += " </tr>\n"
72
72
  # Split, right side output
73
- markup[:right] += "<tr class=\"diff-json-view-line\">\n"
74
- markup[:right] += "<td class=\"diff-json-view-line-operator\">#{lines[:new][i][0].gsub(/\s/, '&nbsp;')}</td>\n"
75
- markup[:right] += "<td class=\"diff-json-view-line-content #{content_highlight_class(:right, lines[:new][i][0])}\">#{lines[:new][i][1].gsub(/\s/, '&nbsp;')}</td>\n"
76
- markup[:right] += "</tr>\n"
73
+ markup[:right] += " <tr class=\"diff-json-view-line\">\n"
74
+ markup[:right] += " <td class=\"diff-json-view-line-operator\"><pre>#{lines[:new][i][0]}</pre></td>\n"
75
+ markup[:right] += " <td class=\"diff-json-view-line-content #{content_highlight_class(:right, lines[:new][i][0])}\"><pre>#{lines[:new][i][1]}</pre></td>\n"
76
+ markup[:right] += " </tr>\n"
77
77
  end
78
78
 
79
79
  markup[:full] += "</table>\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diff_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh MacLachlan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-31 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Diffs two JSON objects and returns a left/right diff view, similar to
14
14
  the command line `diff` utility