Skip to content

Add opt-in binary string diff support#301

Open
gschlager wants to merge 2 commits intosplitwise:mainfrom
gschlager:binary-diff
Open

Add opt-in binary string diff support#301
gschlager wants to merge 2 commits intosplitwise:mainfrom
gschlager:binary-diff

Conversation

@gschlager
Copy link
Copy Markdown
Contributor

Depends on #300

Add a SuperDiff::BinaryString extension that renders ASCII-8BIT strings as hex dumps. Users opt-in by requiring the module:

require 'super_diff/binary_string'

Includes a dedicated differ, inspection tree builder, operation tree builder/tree/flattener, and updates SuperDiff::RSpec::Differ to allow diffs for binary strings (skipping the single-line string short-
circuit).

Hex dumps use 16 bytes per line with offset, hex pairs, and ASCII representation (xxd-style output).

@gschlager
Copy link
Copy Markdown
Contributor Author

@jas14 I wanted to follow up on my PR to see if there’s anything I should address or if you haven’t had the chance to review it yet. No worries either way.

@jas14
Copy link
Copy Markdown
Collaborator

jas14 commented Mar 13, 2026

Hi @gschlager , I haven't forgotten about this, but haven't had the chance to review yet. Apologies for the delay!

@jas14 jas14 self-requested a review March 26, 2026 16:02
Copy link
Copy Markdown
Collaborator

@jas14 jas14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @gschlager , thank you for your contribution and for your patience! I finally had some time to give this PR the time it deserves.

In general, looks excellent. Back to you with a question about the OperationTree prepend and a request to remove the OperationTreeBuilder prepend.

P.S. don't forget to add an entry to the CHANGELOG! 😉

Comment thread lib/super_diff/binary_string/operation_tree_builders/binary_string.rb Outdated
Comment thread lib/super_diff/binary_string.rb Outdated
Comment thread lib/super_diff/binary_string.rb
Comment thread lib/super_diff/binary_string.rb Outdated
Add a `SuperDiff::BinaryString` extension that renders `ASCII-8BIT` strings as hex dumps. Users opt-in by requiring the module:

```
require 'super_diff/binary_string'
```

Includes a dedicated differ, inspection tree builder, operation tree builder/tree/flattener, and updates SuperDiff::RSpec::Differ to allow diffs for binary strings (skipping the single-line string short-
circuit).

Hex dumps use 16 bytes per line with offset, hex pairs, and ASCII representation (xxd-style output).
gschlager added a commit to gschlager/super_diff that referenced this pull request Apr 18, 2026
- Drop redundant should_compare? override; the MultilineString superclass
  already returns false as of splitwise#304.
- Stop registering OperationTreeBuilders::BinaryString and
  OperationTrees::BinaryString as extras. Binary strings nested in
  collections now render via the BinaryString inspection tree builder
  (e.g. `<binary string (32 bytes)>`) instead of producing inline hex
  dumps, and have_attributes no longer risks picking up the binary
  operation tree for a binary-string actual. Top-level binary diffs keep
  working because Differs::BinaryString references the builder directly.
- Add CHANGELOG entry.
gschlager added a commit to gschlager/super_diff that referenced this pull request Apr 18, 2026
- Drop redundant should_compare? override; the MultilineString superclass
  already returns false as of splitwise#304.
- Stop registering OperationTreeBuilders::BinaryString and
  OperationTrees::BinaryString as extras. Binary strings nested in
  collections now render via the BinaryString inspection tree builder
  (e.g. `<binary string (32 bytes)>`) instead of producing inline hex
  dumps, and have_attributes no longer risks picking up the binary
  operation tree for a binary-string actual. Top-level binary diffs keep
  working because Differs::BinaryString references the builder directly.
- Add CHANGELOG entry.
gschlager added a commit to gschlager/super_diff that referenced this pull request Apr 18, 2026
- Drop redundant should_compare? override; the MultilineString superclass
  already returns false as of splitwise#304.
- Stop registering OperationTreeBuilders::BinaryString and
  OperationTrees::BinaryString as extras. Binary strings nested in
  collections now render via the BinaryString inspection tree builder
  (e.g. `<binary string (32 bytes)>`) instead of producing inline hex
  dumps, and have_attributes no longer risks picking up the binary
  operation tree for a binary-string actual. Top-level binary diffs keep
  working because Differs::BinaryString references the builder directly.
- Add CHANGELOG entry.
- Drop redundant should_compare? override; the MultilineString superclass
  already returns false.
- Stop registering OperationTreeBuilders::BinaryString and
  OperationTrees::BinaryString as extras. Binary strings nested in
  collections now render via the BinaryString inspection tree builder
  (e.g. `<binary string (32 bytes)>`) instead of producing inline hex
  dumps, and have_attributes no longer risks picking up the binary
  operation tree for a binary-string actual. Top-level binary diffs keep
  working because Differs::BinaryString references the builder directly.
- Add CHANGELOG entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants