paper_trail_diff 0.6.0 → 0.7.0

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +85 -9
  4. data/lib/paper_trail_diff/activity_root_steps.rb +17 -7
  5. data/lib/paper_trail_diff/analysis_batch.rb +11 -7
  6. data/lib/paper_trail_diff/batched_root_versions.rb +21 -6
  7. data/lib/paper_trail_diff/paper_trail_adapter.rb +63 -23
  8. data/lib/paper_trail_diff/root_version_plan.rb +16 -3
  9. data/lib/paper_trail_diff/root_version_selection.rb +36 -12
  10. data/lib/paper_trail_diff/step.rb +14 -5
  11. data/lib/paper_trail_diff/time_activity_timeline_builder.rb +83 -25
  12. data/lib/paper_trail_diff/time_version_range.rb +6 -3
  13. data/lib/paper_trail_diff/timeline_builder.rb +17 -8
  14. data/lib/paper_trail_diff/timeline_range.rb +6 -3
  15. data/lib/paper_trail_diff/timeline_snapshot_provider.rb +20 -4
  16. data/lib/paper_trail_diff/version.rb +1 -1
  17. data/lib/paper_trail_diff.rb +20 -12
  18. data/sig/generated/paper_trail_diff/activity_root_steps.rbs +7 -2
  19. data/sig/generated/paper_trail_diff/analysis_batch.rbs +6 -4
  20. data/sig/generated/paper_trail_diff/batched_root_versions.rbs +11 -4
  21. data/sig/generated/paper_trail_diff/paper_trail_adapter.rbs +26 -10
  22. data/sig/generated/paper_trail_diff/root_version_plan.rbs +12 -2
  23. data/sig/generated/paper_trail_diff/root_version_selection.rbs +13 -2
  24. data/sig/generated/paper_trail_diff/step.rbs +5 -2
  25. data/sig/generated/paper_trail_diff/time_activity_timeline_builder.rbs +33 -12
  26. data/sig/generated/paper_trail_diff/time_version_range.rbs +4 -2
  27. data/sig/generated/paper_trail_diff/timeline_builder.rbs +5 -2
  28. data/sig/generated/paper_trail_diff/timeline_range.rbs +4 -2
  29. data/sig/generated/paper_trail_diff/timeline_snapshot_provider.rbs +11 -2
  30. data/sig/generated/paper_trail_diff.rbs +8 -8
  31. metadata +4 -4
@@ -12,8 +12,8 @@ module PaperTrailDiff
12
12
  class RootVersionSelection
13
13
  INCOMPLETE: ::String
14
14
 
15
- # : (in_range: Array[untyped], selected: Array[untyped], after_range: untyped, windowed: bool, ?context_required: bool, ?filtered: bool) -> void
16
- def initialize: (in_range: Array[untyped], selected: Array[untyped], after_range: untyped, windowed: bool, ?context_required: bool, ?filtered: bool) -> void
15
+ # : (in_range: Array[untyped], selected: Array[untyped], after_range: untyped, windowed: bool, ?context_required: bool, ?filtered: bool, ?live_endpoint: untyped) -> void
16
+ def initialize: (in_range: Array[untyped], selected: Array[untyped], after_range: untyped, windowed: bool, ?context_required: bool, ?filtered: bool, ?live_endpoint: untyped) -> void
17
17
 
18
18
  # : () -> RootVersionPlan
19
19
  def call: () -> RootVersionPlan
@@ -28,10 +28,18 @@ module PaperTrailDiff
28
28
 
29
29
  @in_range: Array[untyped]
30
30
 
31
+ @live_endpoint: untyped
32
+
31
33
  @selected: Array[untyped]
32
34
 
33
35
  @windowed: bool
34
36
 
37
+ # A window reaching past the last recorded version has only the live record
38
+ # left to show what its final mutation produced. That record is a closing
39
+ # boundary rather than a selected mutation, so it never joins `versions`.
40
+ # : (untyped) -> RootVersionPlan
41
+ def contiguous_plan: (untyped) -> RootVersionPlan
42
+
35
43
  # An activity view still needs a root to reconstruct from even when no root
36
44
  # version falls inside the window, because descendants may have moved.
37
45
  # : () -> RootVersionPlan
@@ -44,6 +52,9 @@ module PaperTrailDiff
44
52
  # : (untyped) -> RootVersionPlan
45
53
  def filtered_plan: (untyped) -> RootVersionPlan
46
54
 
55
+ # : (Array[[untyped, untyped]], untyped) -> RootVersionPlan
56
+ def filtered_plan_for: (Array[[ untyped, untyped ]], untyped) -> RootVersionPlan
57
+
47
58
  # Nothing can follow a destroy, so it never pairs into a step. It is still a
48
59
  # selected mutation, and the activity view closes on the absence it leaves,
49
60
  # so it has to stay a boundary or a filtered report loses the deletion
@@ -13,8 +13,11 @@ module PaperTrailDiff
13
13
 
14
14
  attr_reader diff: Diff
15
15
 
16
- # : (from_version: untyped, to_version: untyped, diff: Diff) -> void
17
- def initialize: (from_version: untyped, to_version: untyped, diff: Diff) -> void
16
+ # `to_version` is nil for the one step that closes on current state, which a
17
+ # window reaching past the last recorded version has to do. Read
18
+ # `to_boundary` instead when a caller may have opted into that.
19
+ # : (from_version: untyped, to_version: untyped, diff: Diff, ?captured_at: untyped) -> void
20
+ def initialize: (from_version: untyped, to_version: untyped, diff: Diff, ?captured_at: untyped) -> void
18
21
 
19
22
  # : () -> bool
20
23
  def empty?: () -> bool
@@ -22,8 +22,19 @@ module PaperTrailDiff
22
22
 
23
23
  @tree: AssociationTree
24
24
 
25
- # : () -> [ActivityHistory, RootVersionPlan, ActivityStep?]
26
- def history_and_versions: () -> [ ActivityHistory, RootVersionPlan, ActivityStep? ]
25
+ # : () -> [ActivityHistory, RootVersionPlan, ActivityStep?, RecordSnapshot?, untyped]
26
+ def history_and_versions: () -> [ ActivityHistory, RootVersionPlan, ActivityStep?, RecordSnapshot?, untyped ]
27
+
28
+ # : (RootVersionPlan, untyped) -> [ActivityHistory, RootVersionPlan, ActivityStep?, RecordSnapshot?, untyped]
29
+ def history_for: (RootVersionPlan, untyped) -> [ ActivityHistory, RootVersionPlan, ActivityStep?, RecordSnapshot?, untyped ]
30
+
31
+ # One live read serves both the closing activity step and the endpoint the
32
+ # analysis reports, which would otherwise reconstruct the graph twice.
33
+ # : (RootVersionPlan) -> RecordSnapshot?
34
+ def current_snapshot: (RootVersionPlan) -> RecordSnapshot?
35
+
36
+ # : (Array[untyped], untyped) -> Array[ActivityEvent]
37
+ def events_through: (Array[untyped], untyped) -> Array[ActivityEvent]
27
38
 
28
39
  # : (Array[untyped], Array[ActivityEvent]) -> ActivityHistory
29
40
  def build_history: (Array[untyped], Array[ActivityEvent]) -> ActivityHistory
@@ -39,22 +50,32 @@ module PaperTrailDiff
39
50
  # : (Array[ActivityEvent], RootVersionPlan) -> Array[ActivityEvent]
40
51
  def selected_events: (Array[ActivityEvent], RootVersionPlan) -> Array[ActivityEvent]
41
52
 
42
- # The window's last selected mutation is the root's own destruction, so the
43
- # timeline closes on the absence it leaves rather than on a later boundary.
44
- # : (ActivityHistory, ActivityEvent?) -> ActivityStep?
45
- def closing_step: (ActivityHistory, ActivityEvent?) -> ActivityStep?
53
+ # A window either closes on the absence its final destruction leaves, or on
54
+ # current state when it reaches past everything recorded. Both are boundaries
55
+ # no version can supply.
56
+ # : (ActivityHistory, ActivityEvent?, RootVersionPlan, untyped, RecordSnapshot?) -> ActivityStep?
57
+ def closing_step: (ActivityHistory, ActivityEvent?, RootVersionPlan, untyped, RecordSnapshot?) -> ActivityStep?
58
+
59
+ # : (ActivityHistory, ActivityEvent) -> ActivityStep
60
+ def destroyed_step: (ActivityHistory, ActivityEvent) -> ActivityStep
61
+
62
+ # The last boundary reached is where current state is compared from, which
63
+ # is the final event rather than the final root version once descendants
64
+ # have moved since it.
65
+ # : (ActivityHistory, untyped, untyped, RecordSnapshot?) -> ActivityStep?
66
+ def current_step: (ActivityHistory, untyped, untyped, RecordSnapshot?) -> ActivityStep?
46
67
 
47
68
  # : (ActivityEvent?) -> bool
48
69
  def terminal_destroy?: (ActivityEvent?) -> bool
49
70
 
50
- # : (Array[untyped]) -> void
51
- def prepare_history: (Array[untyped]) -> void
71
+ # : (Array[untyped], ?end_at: untyped) -> void
72
+ def prepare_history: (Array[untyped], ?end_at: untyped) -> void
52
73
 
53
- # : (Array[untyped]) -> Array[ActivityEvent]
54
- def collect_events: (Array[untyped]) -> Array[ActivityEvent]
74
+ # : (Array[untyped], ?range_end: untyped) -> Array[ActivityEvent]
75
+ def collect_events: (Array[untyped], ?range_end: untyped) -> Array[ActivityEvent]
55
76
 
56
- # : (Array[ActivityEvent], Array[ActivityEvent]) -> bool
57
- def time_events?: (Array[ActivityEvent], Array[ActivityEvent]) -> bool
77
+ # : (Array[ActivityEvent], Array[ActivityEvent], RootVersionPlan) -> bool
78
+ def time_events?: (Array[ActivityEvent], Array[ActivityEvent], RootVersionPlan) -> bool
58
79
 
59
80
  # : (ActivityEvent, Array[ActivityEvent]) -> bool
60
81
  def later_event?: (ActivityEvent, Array[ActivityEvent]) -> bool
@@ -3,8 +3,8 @@
3
3
  module PaperTrailDiff
4
4
  # Selects in-range root versions plus one later reconstruction boundary.
5
5
  class TimeVersionRange
6
- # : (untyped, time_range: TimeRange, ?version_scope: untyped) -> void
7
- def initialize: (untyped, time_range: TimeRange, ?version_scope: untyped) -> void
6
+ # : (untyped, time_range: TimeRange, ?version_scope: untyped, ?live_endpoint: untyped) -> void
7
+ def initialize: (untyped, time_range: TimeRange, ?version_scope: untyped, ?live_endpoint: untyped) -> void
8
8
 
9
9
  # : (?context_required: bool) -> Array[untyped]
10
10
  def select: (?context_required: bool) -> Array[untyped]
@@ -14,6 +14,8 @@ module PaperTrailDiff
14
14
 
15
15
  private
16
16
 
17
+ @live_endpoint: untyped
18
+
17
19
  @record: untyped
18
20
 
19
21
  @time_range: TimeRange
@@ -3,8 +3,8 @@
3
3
  module PaperTrailDiff
4
4
  # Selects and compares a chronological slice of a record's version history.
5
5
  class TimelineBuilder
6
- # : (untyped, from: untyped, to: untyped, snapshotter: untyped, ?within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?) -> void
7
- def initialize: (untyped, from: untyped, to: untyped, snapshotter: untyped, ?within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?) -> void
6
+ # : (untyped, from: untyped, to: untyped, snapshotter: untyped, ?within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?, ?live_endpoint: untyped) -> void
7
+ def initialize: (untyped, from: untyped, to: untyped, snapshotter: untyped, ?within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?, ?live_endpoint: untyped) -> void
8
8
 
9
9
  # : () -> Array[Step]
10
10
  def build: () -> Array[Step]
@@ -23,6 +23,9 @@ module PaperTrailDiff
23
23
  # : (RootVersionPlan) -> [Array[Step], RecordSnapshot?, RecordSnapshot?]
24
24
  def compare_history: (RootVersionPlan) -> [ Array[Step], RecordSnapshot?, RecordSnapshot? ]
25
25
 
26
+ # : (RootVersionPlan) -> Array[Step]
27
+ def build_steps: (RootVersionPlan) -> Array[Step]
28
+
26
29
  # : () -> [Array[Step], nil, nil]
27
30
  def empty_history: () -> [ Array[Step], nil, nil ]
28
31
 
@@ -11,8 +11,8 @@ module PaperTrailDiff
11
11
 
12
12
  attr_reader time_range: TimeRange?
13
13
 
14
- # : (untyped, from: untyped, to: untyped, within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?) -> void
15
- def initialize: (untyped, from: untyped, to: untyped, within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?) -> void
14
+ # : (untyped, from: untyped, to: untyped, within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?, ?live_endpoint: untyped) -> void
15
+ def initialize: (untyped, from: untyped, to: untyped, within: untyped, ?versions: Array[untyped]?, ?version_scope: untyped, ?plan: RootVersionPlan?, ?live_endpoint: untyped) -> void
16
16
 
17
17
  # A record with no versions has no first or last boundary to resolve, which
18
18
  # is an empty history rather than a bad request.
@@ -42,6 +42,8 @@ module PaperTrailDiff
42
42
 
43
43
  @from: untyped
44
44
 
45
+ @live_endpoint: untyped
46
+
45
47
  @plan: RootVersionPlan?
46
48
 
47
49
  @record: untyped
@@ -3,15 +3,24 @@
3
3
  module PaperTrailDiff
4
4
  # Gives TimelineBuilder one-argument access to a range-prepared snapshot store.
5
5
  class TimelineSnapshotProvider
6
- # : (HistoricalSnapshotStore) -> void
7
- def initialize: (HistoricalSnapshotStore) -> void
6
+ # : (HistoricalSnapshotStore, ?live_snapshotter: untyped) -> void
7
+ def initialize: (HistoricalSnapshotStore, ?live_snapshotter: untyped) -> void
8
8
 
9
9
  # : (untyped, Array[untyped]) -> void
10
10
  def prepare: (untyped, Array[untyped]) -> void
11
11
 
12
+ # A window closing on current state ends at the live record rather than at a
13
+ # version, which is the one endpoint no version history can reconstruct.
12
14
  # : (untyped) -> RecordSnapshot?
13
15
  def call: (untyped) -> RecordSnapshot?
14
16
 
17
+ private
18
+
19
+ # : (untyped) -> RecordSnapshot?
20
+ def live_snapshot: (untyped) -> RecordSnapshot?
21
+
22
+ @live_snapshotter: untyped
23
+
15
24
  @store: HistoricalSnapshotStore
16
25
  end
17
26
  end
@@ -17,24 +17,24 @@ module PaperTrailDiff
17
17
  def self.compare_many: (Array[comparison_input], ?associations: Array[String | Symbol], ?ignore: ignore_option, ?reload_live_endpoints: bool) -> comparison_results
18
18
 
19
19
  # Compares every adjacent reconstructed state in an inclusive version range.
20
- # : (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?version_scope: untyped) -> Array[Step]
21
- def self.timeline: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?version_scope: untyped) -> Array[Step]
20
+ # : (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?version_scope: untyped, ?close_on: Symbol?) -> Array[Step]
21
+ def self.timeline: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?version_scope: untyped, ?close_on: Symbol?) -> Array[Step]
22
22
 
23
23
  # Compares adjacent root and selected-descendant activity boundaries.
24
24
  # `reload_live_endpoints:` applies only when `to:` is a current record; the
25
25
  # other range forms never read live state.
26
- # : (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?reload_live_endpoints: bool, ?version_scope: untyped) -> Array[ActivityStep]
27
- def self.activity_timeline: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?reload_live_endpoints: bool, ?version_scope: untyped) -> Array[ActivityStep]
26
+ # : (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?reload_live_endpoints: bool, ?version_scope: untyped, ?close_on: Symbol?) -> Array[ActivityStep]
27
+ def self.activity_timeline: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?reload_live_endpoints: bool, ?version_scope: untyped, ?close_on: Symbol?) -> Array[ActivityStep]
28
28
 
29
29
  # Builds an endpoint diff and root-checkpoint timeline while normalizing each version once.
30
- # : (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped) -> Analysis
31
- def self.analyze: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped) -> Analysis
30
+ # : (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?) -> Analysis
31
+ def self.analyze: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?) -> Analysis
32
32
 
33
33
  # Analyzes many roots over one shared time window, preparing their selected
34
34
  # history once for the batch instead of once per record. Roots with no
35
35
  # versions in the window return an empty `Analysis`.
36
- # : (Array[untyped], ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped) -> Hash[identity, Analysis]
37
- def self.analyze_many: (Array[untyped], ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped) -> Hash[identity, Analysis]
36
+ # : (Array[untyped], ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?) -> Hash[identity, Analysis]
37
+ def self.analyze_many: (Array[untyped], ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?) -> Hash[identity, Analysis]
38
38
 
39
39
  # Returns the association macros this release can normalize.
40
40
  # : () -> Array[Symbol]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_trail_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Williams
@@ -200,11 +200,11 @@ licenses:
200
200
  metadata:
201
201
  allowed_push_host: https://rubygems.org
202
202
  bug_tracker_uri: https://github.com/aheathwilliams/paper_trail_diff/issues
203
- changelog_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.6.0/CHANGELOG.md
204
- documentation_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.6.0/README.md
203
+ changelog_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.7.0/CHANGELOG.md
204
+ documentation_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.7.0/README.md
205
205
  homepage_uri: https://github.com/aheathwilliams/paper_trail_diff
206
206
  rubygems_mfa_required: 'true'
207
- source_code_uri: https://github.com/aheathwilliams/paper_trail_diff/tree/v0.6.0
207
+ source_code_uri: https://github.com/aheathwilliams/paper_trail_diff/tree/v0.7.0
208
208
  rdoc_options: []
209
209
  require_paths:
210
210
  - lib