diff_json 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diff_json/diff.rb +23 -13
- data/lib/diff_json/output/html_output.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e7db1864f01af8a4b9358314fb1780e685f91a76a0e31a336b4d25c004631ff
|
4
|
+
data.tar.gz: b7243d22d10d0f6e5319c0063eff1158b488fa9548113df53a2ccfe343ce5fbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9212e41b30d1af3b8de20c1af4a74b4b1c48dffdacad635edbbf7d6096502329a1eef5a084b52a75afb421cf47bbc9f7a00a9d660b1e165227ddc9461e0e02e6
|
7
|
+
data.tar.gz: eef4f38448a7c71c37dd36ed1e3cc832b6bdeee81bc9656b9c4d38fa6d94cc43e2c813313a78baf6ec72f5b7987f89664f5ba8e992e5c408f54f4d7bb0cc701d
|
data/lib/diff_json/diff.rb
CHANGED
@@ -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
|
45
|
-
return
|
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
|
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.
|
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-
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: require_all
|