record_diff 0.1.0 → 0.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3573eafdce630fe361b7dd3bc6846e791bbee0cea93220108521ea6bdd11b996
|
4
|
+
data.tar.gz: 18ae98bafb72fdabbed18e4992a8b0b1d5ed846ffd7c19d01fa97c7aad8ea590
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e4ab4485468259bad818c474f01ec421135c5febf80db47834afe6f10c8d7610600270812e707c18afb63d339e20515b2c0a3ef17be423b7d495e03963d4c4
|
7
|
+
data.tar.gz: 2d1ab887cabfea448ec36a7e580f570538767f056ee057a596403a3726bad1595f316ed7991d7bf27de2f8ab70040f9bd20bec999e4da13498dd79f7e78d774d
|
data/lib/record_diff/matcher.rb
CHANGED
@@ -68,8 +68,15 @@ module RecordDiff
|
|
68
68
|
|
69
69
|
# @return
|
70
70
|
def generate_result_obj(key, before, after) # rubocop:disable MethodLength
|
71
|
-
before_compare =
|
72
|
-
|
71
|
+
before_compare, after_compare = generate_compares before, after
|
72
|
+
if before_compare.is_a?(StandardError) ||
|
73
|
+
after_compare.is_a?(StandardError)
|
74
|
+
return Results::ErroredResult.new id: key,
|
75
|
+
before: before,
|
76
|
+
before_compare: before_compare,
|
77
|
+
after: after,
|
78
|
+
after_compare: after_compare
|
79
|
+
end
|
73
80
|
if before_compare.nil?
|
74
81
|
return Results::AddedResult.new id: key,
|
75
82
|
after: after,
|
@@ -93,5 +100,19 @@ module RecordDiff
|
|
93
100
|
after: after, after_compare: after_compare
|
94
101
|
)
|
95
102
|
end
|
103
|
+
|
104
|
+
def generate_compares(before, after) # rubocop:disable MethodLength
|
105
|
+
begin
|
106
|
+
before_compare = before ? before_transform.call(before) : nil
|
107
|
+
rescue StandardError => e
|
108
|
+
before_compare = e
|
109
|
+
end
|
110
|
+
begin
|
111
|
+
after_compare = after ? after_transform.call(after) : nil
|
112
|
+
rescue StandardError => e
|
113
|
+
after_compare = e
|
114
|
+
end
|
115
|
+
[before_compare, after_compare]
|
116
|
+
end
|
96
117
|
end
|
97
118
|
end
|
data/lib/record_diff/results.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RecordDiff
|
4
|
+
module Results
|
5
|
+
# If the ID can be matched, but the two records have changed.
|
6
|
+
class ErroredResult < AbstractResult
|
7
|
+
def initialize(id:, after:, before:, after_compare:, before_compare:)
|
8
|
+
@id = id
|
9
|
+
@after_original = after
|
10
|
+
@after_compare = after_compare
|
11
|
+
@before_original = before
|
12
|
+
@before_compare = before_compare
|
13
|
+
end
|
14
|
+
|
15
|
+
def error?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/record_diff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Seviora
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/record_diff/results/added_result.rb
|
153
153
|
- lib/record_diff/results/changed_result.rb
|
154
154
|
- lib/record_diff/results/dropped_result.rb
|
155
|
+
- lib/record_diff/results/errored_result.rb
|
155
156
|
- lib/record_diff/results/unchanged_result.rb
|
156
157
|
- lib/record_diff/version.rb
|
157
158
|
- record_diff.gemspec
|