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

pulibrary / orangelight / 62bad3f1-d46d-40af-822c-403d653da2a8

17 Jun 2025 05:30PM UTC coverage: 0.447% (-94.9%) from 95.337%
62bad3f1-d46d-40af-822c-403d653da2a8

push

circleci

maxkadel
Install chrome & chromedriver for smoke specs

43 of 9610 relevant lines covered (0.45%)

0.01 hits per line

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

0.0
/app/components/holdings/online_holdings_component.rb
1
# frozen_string_literal: true
2

3
# This component is responsible for displaying a brief description of
4
# a document's online holdings for consice contexts like the search
5
# results page
6
class Holdings::OnlineHoldingsComponent < ViewComponent::Base
×
7
  def initialize(document:)
×
8
    @document = document
×
9
  end
×
10

11
  def render?
×
12
    links.present?
×
13
  end
×
14

15
  private
×
16

17
    attr_reader :document
×
18

19
    def links
×
20
      @links ||= marc_links + portfolio_links
×
21
    end
×
22

23
    # Generate an Array of <div> elements wrapping links to proxied service endpoints for access
24
    # Takes first 2 links for pairing with online holdings in search results
25
    # @return [Array<String>] array containing the links in the <div>'s
26
    def marc_links
×
27
      electronic_access = document['electronic_access_1display']
×
28
      urls = []
×
29
      if electronic_access
×
30
        links_hash = JSON.parse(electronic_access)
×
31
        links_hash.first(2).each do |url, text|
×
32
          link = link_to(text.first, EzProxyService.ez_proxy_url(url), target: '_blank', rel: 'noopener')
×
33
          link = "#{text[1]}: ".html_safe + link if text[1]
×
34
          urls << content_tag(:div, link, class: 'library-location')
×
35
        end
×
36
      end
×
37
      urls
×
38
    end
×
39

40
    # Returns electronic portfolio links for Alma records.
41
    # @return [Array<String>] array containing the links
42
    def portfolio_links
×
43
      return [] if document.try(:electronic_portfolios).blank?
×
44
      document.electronic_portfolios.map do |portfolio|
×
45
        content_tag(:div, class: 'library-location') do
×
46
          link_to(portfolio["title"], portfolio["url"], target: '_blank', rel: 'noopener')
×
47
        end
×
48
      end
×
49
    end
×
50
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