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

benwbrum / fromthepage / 17387282326

01 Sep 2025 09:13PM UTC coverage: 64.405%. Remained the same
17387282326

push

github

web-flow
4857 - Require rubocop step in CI (#4858)

* 4857 - Require rubocop step in CI

* 4865 - Organize gemfiles

1790 of 3303 branches covered (54.19%)

Branch coverage included in aggregate %.

839 of 1497 new or added lines in 133 files covered. (56.05%)

43 existing lines in 29 files now uncovered.

7928 of 11786 relevant lines covered (67.27%)

103.82 hits per line

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

18.75
/lib/diff_tools.rb
1
module DiffTools
1✔
2
  def self.diff_and_replace(text_a, text_b, replacement)
1✔
3
    # this method compares two strings and produces a third string which contains all identical text, with the differences replaced by the replacement string
4
    # compare the two strings
5
    diff = Diffy::Diff.new(text_a, text_b, include_diff_info: true)
×
6
    # diffly has code which marks up the differences within a line in HTML, using strong tags to identify words
7
    # we want to replace the words which are different with the replacement string
8
    # it's easiest to convert the diffly output to HTML, then use Nokogiri to parse the HTML and replace the words
9
    # convert the diffly output to HTML
10
    diff_html = diff.to_s(:html)
×
11
    # parse the HTML
12
    doc = Nokogiri::HTML(diff_html)
×
13
    # iterate through the strong tags
14
    doc.search('strong').each do |strong|
×
15
      # replace the content of the strong tag with the replacement string
16
      strong.content = replacement
×
17
    end
18
    # now we want to take the HTML and convert it back to plaintext
19
    lines = []
×
20
    # iterate through the li tags
21
    doc.search('li').each do |li|
×
22
      # if the li tag has a class of del, ignore it
NEW
23
      next if [ 'del', 'diff-comment', 'diff-block-info' ].include? li['class']
×
24
      # add the plaintext content of the li tag to the lines array
25
      lines << li.content
×
26
    end
27
    # return the lines array joined by newlines
28
    lines.join("\n")
×
29
  end
30

31

32
  def self.replace_words(text, replacement)
1✔
33
    # find all the words in the text which contain the replacement string, and substitute them with the replacement string
34
    diff.gsub(/\b\w+#{replacement}\w+\b/m, replacement)
×
35
  end
36
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