• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

halostatue / diff-lcs / 46309878384
95%

Build:
DEFAULT BRANCH: main
Ran 29 Nov 2026 09:03PM UTC
Jobs 1
Files 9
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

29 Nov 2026 09:02PM UTC coverage: 94.754% (+1.3%) from 93.499%
46309878384

push

github

halostatue
feat: Extract diff output from Ldiff into Hunk

The hunk merging and output logic was part of Diff::LCS::Ldiff#diff?,
which requires file information (name and modification time) and an
output stream, so it could not be reused to display the differences
between two sequences of lines.

This logic now lives in two class methods on Diff::LCS::Hunk:

- Diff::LCS::Hunk.from_diff(data_old, data_new, context = 3) returns
  the hunks for the differences, merging the hunks that overlap because
  of their context.

- Diff::LCS::Hunk.diff(data_old, data_new, format = :old, context = 3)
  returns the diff string in the old, unified, or context format,
  without the file header lines, in the encoding of the lines. It
  rejects an unknown format even when there are no differences.

Both raise ArgumentError for a context which is not a non-negative
Integer. The context defaults to 3 lines, as diff -u and diff -c do,
so that Hunk.diff(data_old, data_new, :unified) gives the expected
unified diff.

The old format has no context lines. Hunk#diff(:old) used the range of
the whole hunk, so a hunk with context printed the context lines as
changes, and warned when the hunk had more than one block. It now
writes each block of the hunk on its own, with its own line numbers, so
the old format output does not depend on the context.

Hunk.from_diff and Hunk.diff treat a sequence holding one empty string
as an empty file, as Hunk already did for its line numbers, so they
give the same output as for an empty sequence instead of an invalid
unified hunk ("@@ -0,0 +1 @@" followed by a removed line). The lines
must keep their line endings, as String#lines returns them; this is now
documented. hunk.rb now requires diff/lcs, which its class methods use.

Diff::LCS::Ldiff#diff? uses Diff::LCS::Hunk.diff and keeps the option
handling, binary detection, and file headers. Its output is unchanged.
It now consistently returns true or false, and an unreachable branch
for the ed format, which... (continued)

626 of 767 branches covered (81.62%)

61 of 61 new or added lines in 2 files covered. (100.0%)

1 existing line in 1 file now uncovered.

885 of 934 relevant lines covered (94.75%)

38239.11 hits per line

Coverage Regressions

Lines Coverage ∆ File
1
79.01
1.93% lib/diff/lcs/ldiff.rb
Jobs
ID Job ID Ran Files Coverage
1 46309878384.1 29 Nov 2026 09:03PM UTC 18
94.75
GitHub Action Run
Source Files on build 46309878384
  • Tree
  • List 9
  • Changed 9
  • Source Changed 2
  • Coverage Changed 9
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #46309878384
  • aa7dcf8c on github
  • Prev Build on main (#46082760043)
  • Next Build on main (#46319338407)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc