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

pulibrary / pdc_describe / cace366a-ffad-45f1-9b60-678e607fa527

14 May 2024 02:21PM UTC coverage: 60.862% (-35.0%) from 95.908%
cace366a-ffad-45f1-9b60-678e607fa527

push

circleci

jrgriffiniii
wip

1 of 3 new or added lines in 2 files covered. (33.33%)

1194 existing lines in 57 files now uncovered.

2076 of 3411 relevant lines covered (60.86%)

22.71 hits per line

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

90.0
/app/helpers/application_helper.rb
1
# frozen_string_literal: true
2
module ApplicationHelper
1✔
3
  ##
4
  # Attributes to add to the <html> tag (e.g. lang and dir)
5
  # @return [Hash]
6
  def html_tag_attributes
1✔
7
    { lang: I18n.locale }
53✔
8
  end
9

10
  def pre_curation_uploads_file_name(file:)
1✔
UNCOV
11
    value = file.filename.to_s
×
UNCOV
12
    return if value.blank?
×
13

UNCOV
14
    value[0..79]
×
15
  end
16
  alias post_curation_uploads_file_name pre_curation_uploads_file_name
1✔
17

18
  def ark_url(ark_value)
1✔
19
    return nil if ark_value.blank?
10✔
20
    # This was originally in Work#ark_url as: "https://ezid.cdlib.org/id/#{ark}"
21
    "http://arks.princeton.edu/#{ark_value}"
10✔
22
  end
23

24
  def doi_url(doi_value)
1✔
25
    return nil if doi_value.blank?
22✔
26
    "https://doi.org/#{doi_value}"
22✔
27
  end
28

29
  # Renders citation information APA-ish and BibTeX.
30
  # Notice that the only the APA style is visible, the BibTeX citataion is enabled via JavaScript.
31
  def render_cite_as(work)
1✔
32
    creators = work.resource.creators.map { |creator| "#{creator.family_name}, #{creator.given_name}" }
113✔
33
    citation = DatasetCitation.new(creators, [work.resource.publication_year], work.resource.titles.first.title, work.resource.resource_type, work.resource.publisher, work.resource.doi)
11✔
34
    return if citation.apa.nil?
11✔
35
    citation_html(work, citation)
11✔
36
  end
37

38
  def citation_html(work, citation)
1✔
39
    apa = citation.apa
11✔
40
    bibtex = citation.bibtex
11✔
41
    bibtex_html = html_escape(bibtex).gsub("\r\n", "<br/>").gsub("\t", "  ").gsub("  ", "&nbsp;&nbsp;")
11✔
42
    bibtex_text = html_escape(bibtex).gsub("\t", "  ")
11✔
43

44
    html = apa_section(apa) + "\n" + bibtex_section(work, bibtex_html, bibtex_text)
11✔
45
    # rubocop:disable Rails/OutputSafety
46
    html.html_safe
11✔
47
    # rubocop:enable Rails/OutputSafety
48
  end
49

50
  def bibtex_section(work, bibtex_html, bibtex_text)
1✔
51
    <<-HTML
11✔
52
    <div class="citation-bibtex-container hidden-element">
53
      <div class="bibtex-citation">#{bibtex_html}</div>
54
      <button id="copy-bibtext-citation-button" class="copy-citation-button btn btn-sm" data-style="BibTeX" data-text="#{bibtex_text}" title="Copy BibTeX citation to the clipboard">
55
        <i class="bi bi-clipboard" title="Copy BibTeX citation to the clipboard"></i>
56
        <span class="copy-citation-label-normal">COPY</span>
57
      </button>
58
      <button id="download-bibtex" class="btn btn-sm" data-url="#{work_bibtex_url(id: work.id)}" title="Download BibTeX citation to a file">
59
        <i class="bi bi-file-arrow-down" title="Download BibTeX citation to a file"></i>
60
        <span class="copy-citation-label-normal">DOWNLOAD</span>
61
      </button>
62
    </div>
63
  HTML
64
  end
65

66
  def apa_section(apa)
1✔
67
    <<-HTML
11✔
68
    <div class="citation-apa-container">
69
      <div class="apa-citation">#{html_escape(apa)}</div>
70
      <button id="copy-apa-citation-button" class="copy-citation-button btn btn-sm" data-style="APA" data-text="#{html_escape(apa)}" title="Copy citation to the clipboard">
71
        <i class="bi bi-clipboard" title="Copy citation to the clipboard"></i>
72
        <span class="copy-citation-label-normal">COPY</span>
73
      </button>
74
    </div>
75
    HTML
76
  end
77
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