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

halostatue / diff-lcs / 20612882577

31 Dec 2025 05:35AM UTC coverage: 91.336% (+3.0%) from 88.366%
20612882577

Pull #214

github

web-flow
Merge 7390c6363 into 9b507ea7c
Pull Request #214: feat: diff-lcs 2

400 of 597 branches covered (67.0%)

282 of 301 new or added lines in 7 files covered. (93.69%)

1 existing line in 1 file now uncovered.

622 of 681 relevant lines covered (91.34%)

291.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
/lib/diff/lcs/block.rb
1
# frozen_string_literal: true
2

3
Diff::LCS::Block = Data.define(:changes, :insert, :remove) # :nodoc:
2✔
4

5
# A block is an operation removing, adding, or changing a group of items, a list of
6
# changes, where each change adds or deletes a single item.
7
#
8
# Used by bin/ldiff.
9
class Diff::LCS::Block
2✔
10
  def self.from_chunk(chunk)
2✔
11
    changes, insert, remove = [], [], []
18✔
12

13
    chunk.each do
18✔
14
      changes << _1
38✔
15
      remove << _1 if _1.deleting?
38✔
16
      insert << _1 if _1.adding?
38✔
17
    end
18

19
    new(changes: changes.freeze, remove: remove.freeze, insert: insert.freeze)
18✔
20
  end
21

22
  class << self
2✔
23
    private :new, :[]
2✔
24
  end
25

26
  private :with
2✔
27

28
  def diff_size = insert.size - remove.size
2✔
29

30
  def op
2✔
31
    case [remove, insert]
8!
32
    # Unchanged
×
NEW
33
    in [[], []] then "^"
×
34
    # Delete
×
NEW
35
    in [_, []] then "-"
×
36
    # Insert
×
NEW
37
    in [[], _] then "+"
×
38
    # Conflict
4✔
39
    in [_, _] then "!"
8✔
40
    end
41
  end
42
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc