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

pulibrary / pdc_describe / 4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

07 Apr 2025 06:36PM UTC coverage: 1.283% (-94.6%) from 95.862%
4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

Pull #1994

circleci

hectorcorrea
Switched to use the autocomplete that we aleady use for ROR. Integrated it with the existing logic for creators
Pull Request #1994: Started adding auto complete to contributors

0 of 46 new or added lines in 2 files covered. (0.0%)

4806 existing lines in 74 files now uncovered.

65 of 5065 relevant lines covered (1.28%)

0.01 hits per line

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

0.0
/app/lib/diff_tools.rb
1
# frozen_string_literal: true
2

UNCOV
3
require "diff/lcs"
×
4

UNCOV
5
module DiffTools
×
UNCOV
6
  class SimpleDiff
×
UNCOV
7
    def initialize(old_value, new_value)
×
8
      # /\b/ matches word boundaries.
9
      # It is a zero-length match before and after each word,
10
      # and it preserves the whitespace between words.
11
      #
12
      # "cat dog".split /\b/ == ["cat", " ", "dog"]
UNCOV
13
      old_value = old_value.to_s.split(/\b/)
×
UNCOV
14
      new_value = new_value.to_s.split(/\b/)
×
UNCOV
15
      @changes = ::Diff::LCS.sdiff(old_value, new_value).chunk(&:action).map do |action, changes|
×
UNCOV
16
        {
×
UNCOV
17
          action:,
×
UNCOV
18
          old: changes.map(&:old_element).join,
×
UNCOV
19
          new: changes.map(&:new_element).join
×
UNCOV
20
        }
×
UNCOV
21
      end
×
UNCOV
22
    end
×
23

UNCOV
24
    def to_html
×
UNCOV
25
      @changes.map do |chunk|
×
UNCOV
26
        old_html = DiffTools.value_to_html(chunk[:old])
×
UNCOV
27
        new_html = DiffTools.value_to_html(chunk[:new])
×
UNCOV
28
        if chunk[:action] == "="
×
UNCOV
29
          new_html
×
UNCOV
30
        else
×
UNCOV
31
          (old_html.empty? ? "" : "<del>#{old_html}</del>") + \
×
UNCOV
32
            (new_html.empty? ? "" : "<ins>#{new_html}</ins>")
×
UNCOV
33
        end
×
UNCOV
34
      end.join
×
UNCOV
35
    end
×
UNCOV
36
  end
×
37

UNCOV
38
  def self.value_to_html(value)
×
UNCOV
39
    too_many_words_re = /
×
UNCOV
40
      ((?:\S+\s+){3}) # group 1: Three words, including trailing space
×
UNCOV
41
      (.+)            # group 2: Drop this
×
UNCOV
42
      ((?:\s+\S+){3}) # group 3: Three words, including leading space
×
UNCOV
43
    /x
×
UNCOV
44
    ellipsis = value.gsub(too_many_words_re, '\1...\3')
×
UNCOV
45
    CGI.escapeHTML(ellipsis)
×
UNCOV
46
  end
×
UNCOV
47
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

© 2025 Coveralls, Inc