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: 29c632816fed5fc31fda26b8bcb9c0d30b519d8c9b6d60b9f24d678e1d21710b
4
- data.tar.gz: ff03c14cd3d88e7337469c09087e1ab03f7393deb0d85e4ce3c44695d2917ea7
3
+ metadata.gz: 3573eafdce630fe361b7dd3bc6846e791bbee0cea93220108521ea6bdd11b996
4
+ data.tar.gz: 18ae98bafb72fdabbed18e4992a8b0b1d5ed846ffd7c19d01fa97c7aad8ea590
5
5
  SHA512:
6
- metadata.gz: c0065a822e6a303a54bcdba9d8fec50f68bf150a5921613212d4fcc0d4aaec747332b100ce1e9931c273adcd361fa16dc3e9be47c51426ff29ba8fd0dff242cf
7
- data.tar.gz: 679afedd3fe3e20a7e37b4181cc0263b474f79af7605bc40756a24c140192db1fbcce0d8b2c220042d9d4aa27486dafd1449c3acef83caacc28e16d66e49440a
6
+ metadata.gz: 64e4ab4485468259bad818c474f01ec421135c5febf80db47834afe6f10c8d7610600270812e707c18afb63d339e20515b2c0a3ef17be423b7d495e03963d4c4
7
+ data.tar.gz: 2d1ab887cabfea448ec36a7e580f570538767f056ee057a596403a3726bad1595f316ed7991d7bf27de2f8ab70040f9bd20bec999e4da13498dd79f7e78d774d
@@ -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 = before ? before_transform.call(before) : nil
72
- after_compare = after ? after_transform.call(after) : nil
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
@@ -22,5 +22,13 @@ module RecordDiff
22
22
  def dropped
23
23
  select(&:dropped?)
24
24
  end
25
+
26
+ def errored
27
+ select(&:error?)
28
+ end
29
+
30
+ def all
31
+ self
32
+ end
25
33
  end
26
34
  end
@@ -5,6 +5,7 @@ require_relative 'results/added_result'
5
5
  require_relative 'results/changed_result'
6
6
  require_relative 'results/dropped_result'
7
7
  require_relative 'results/unchanged_result'
8
+ require_relative 'results/errored_result'
8
9
 
9
10
  module RecordDiff
10
11
  # Contains Result types.
@@ -28,6 +28,10 @@ module RecordDiff
28
28
  def dropped?
29
29
  false
30
30
  end
31
+
32
+ def error?
33
+ false
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RecordDiff
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
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.1.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-09-03 00:00:00.000000000 Z
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