diff_json 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8842da0d92100c794a26b185b76c6a2575ebb40c31b0592b89e6cf306321c4cc
4
- data.tar.gz: 9eac3260768d1d24c93651958581ff177de269cae6fe5f414c6dff2551a01e85
3
+ metadata.gz: 8e7db1864f01af8a4b9358314fb1780e685f91a76a0e31a336b4d25c004631ff
4
+ data.tar.gz: b7243d22d10d0f6e5319c0063eff1158b488fa9548113df53a2ccfe343ce5fbb
5
5
  SHA512:
6
- metadata.gz: 18a92b17dea19c9e2e365d2297202266fb4b8113443ae8c34f7b531133c156af984daad3383e3dc3b746615462c4d2163869740c0654d94267e5096967b8c360
7
- data.tar.gz: ed0a68450920a13056661940c72a8be5a8f7c4a3040d7a1817724c6b032db555605e9675b5307f46779bef647a5a5026acf0a9c1bbdd624cce63aaf12cdea729
6
+ metadata.gz: 9212e41b30d1af3b8de20c1af4a74b4b1c48dffdacad635edbbf7d6096502329a1eef5a084b52a75afb421cf47bbc9f7a00a9d660b1e165227ddc9461e0e02e6
7
+ data.tar.gz: eef4f38448a7c71c37dd36ed1e3cc832b6bdeee81bc9656b9c4d38fa6d94cc43e2c813313a78baf6ec72f5b7987f89664f5ba8e992e5c408f54f4d7bb0cc701d
@@ -7,6 +7,16 @@ module DiffJson
7
7
  return case return_type
8
8
  when :raw
9
9
  completed_diff
10
+ when :patch
11
+ patch_operations = []
12
+
13
+ completed_diff.diff.each do |path, operations|
14
+ operations.each do |op|
15
+ patch_operations << op if [:add, :replace, :remove].include?(op[:op]) or (op[:op] == :move and path == op[:from])
16
+ end
17
+ end
18
+
19
+ return patch_operations
10
20
  when :html
11
21
  HtmlOutput.new(completed_diff, **output_opts)
12
22
  end
@@ -41,14 +51,25 @@ module DiffJson
41
51
  @sub_diffs = generate_sub_diffs
42
52
  end
43
53
 
44
- def json_map(version = :old)
45
- return (version == :old ? @old_map : @new_map)
54
+ def count(count_type = :all)
55
+ return case count_type
56
+ when :ignore, :add, :replace, :remove, :move, :update
57
+ @counts[count_type] || 0
58
+ when :total
59
+ @counts.values.sum
60
+ else
61
+ @counts
62
+ end
46
63
  end
47
64
 
48
65
  def diff
49
66
  return @diff
50
67
  end
51
68
 
69
+ def json_map(version = :old)
70
+ return (version == :old ? @old_map : @new_map)
71
+ end
72
+
52
73
  def paths(version = :joint)
53
74
  return case version
54
75
  when :old
@@ -60,17 +81,6 @@ module DiffJson
60
81
  end
61
82
  end
62
83
 
63
- def count(count_type = :all)
64
- return case count_type
65
- when :ignore, :add, :replace, :remove, :move, :update
66
- @counts[count_type] || 0
67
- when :total
68
- @counts.values.sum
69
- else
70
- @counts
71
- end
72
- end
73
-
74
84
  def sub_diffs
75
85
  return @sub_diffs
76
86
  end
@@ -9,14 +9,14 @@ module DiffJson
9
9
  @markup = build
10
10
  end
11
11
 
12
- def markup
13
- return @markup
14
- end
15
-
16
12
  def diff
17
13
  return @diff
18
14
  end
19
15
 
16
+ def markup
17
+ return @markup
18
+ end
19
+
20
20
  private
21
21
 
22
22
  def build
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: 1.0.1
4
+ version: 1.0.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: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all