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

pulibrary / orangelight / fdcd3310-12d3-4e80-823f-8ca1a6a1953a

17 Dec 2024 10:50PM UTC coverage: 95.739% (-0.7%) from 96.415%
fdcd3310-12d3-4e80-823f-8ca1a6a1953a

Pull #4582

circleci

web-flow
Merge pull request #4656 from pulibrary/blacklight-8.7.0

bundle update blacklight 8.7.0
Pull Request #4582: Blacklight upgrade to 8.6.1

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

50 existing lines in 4 files now uncovered.

6022 of 6290 relevant lines covered (95.74%)

1512.76 hits per line

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

0.0
/app/models/concerns/blacklight/document/email.rb
1
# frozen_string_literal: true
2

3
# This module provides the body of an email export based on the document's semantic values
UNCOV
4
module Blacklight
×
UNCOV
5
  module Document
×
UNCOV
6
    module Email
×
UNCOV
7
      include ActionView::Helpers::UrlHelper
×
8
      # Return a text string that will be the body of the email
UNCOV
9
      def to_email_text
×
UNCOV
10
        body = []
×
UNCOV
11
        add_bibliographic_text(body)
×
UNCOV
12
        add_online_text(body, self[:electronic_access_1display], self[:electronic_portfolio_s])
×
UNCOV
13
        body.join("\n") unless body.empty?
×
UNCOV
14
      end
×
15

UNCOV
16
      private
×
17

UNCOV
18
        def add_single_valued_field(body, i18_label, value)
×
UNCOV
19
          body << I18n.t(i18_label, value:) if value.present?
×
UNCOV
20
        end
×
21

UNCOV
22
        def add_multi_valued_field(body, i18_label, value)
×
UNCOV
23
          value.each { |v| add_single_valued_field(body, i18_label, v) } if value.present?
×
UNCOV
24
        end
×
25

UNCOV
26
        def add_bibliographic_text(body)
×
UNCOV
27
          add_single_valued_field(body, 'blacklight.email.text.title', self[:title_vern_display])
×
UNCOV
28
          add_single_valued_field(body, 'blacklight.email.text.title', self[:title_display])
×
UNCOV
29
          add_multi_valued_field(body, 'blacklight.email.text.author', self[:author_display])
×
UNCOV
30
          add_multi_valued_field(body, 'blacklight.email.text.publish', self[:pub_created_display])
×
UNCOV
31
          add_multi_valued_field(body, 'blacklight.email.text.format', self[:format])
×
UNCOV
32
        end
×
33

UNCOV
34
        def add_online_text(body, links_field, portfolio_fields)
×
UNCOV
35
          body << I18n.t('blacklight.email.text.online') if links_field.present? || portfolio_fields.present?
×
UNCOV
36
          if links_field.present?
×
UNCOV
37
            links = JSON.parse(links_field)
×
UNCOV
38
            links.each do |url, text|
×
UNCOV
39
              link = "#{text[0]}: #{url}"
×
UNCOV
40
              link = "#{text[1]} - " + link if text[1]
×
UNCOV
41
              body << "\t" + link
×
UNCOV
42
            end
×
UNCOV
43
          end
×
UNCOV
44
          if portfolio_fields.present?
×
UNCOV
45
            portfolio_fields.each do |portfolio_field|
×
UNCOV
46
              portfolio = JSON.parse(portfolio_field)
×
UNCOV
47
              link = "#{portfolio['title']}: #{portfolio['url']}"
×
UNCOV
48
              body << "\t" + link
×
UNCOV
49
            end
×
UNCOV
50
          end
×
UNCOV
51
        end
×
UNCOV
52
    end
×
UNCOV
53
  end
×
UNCOV
54
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