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

pulibrary / orangelight / 00dbc10b-d747-4ad7-b211-7b26d753abbb

14 Aug 2025 01:25PM UTC coverage: 0.483% (-94.9%) from 95.343%
00dbc10b-d747-4ad7-b211-7b26d753abbb

push

circleci

web-flow
Merge pull request #5181 from pulibrary/dependabot/bundler/activestorage-7.2.2.2

Bump activestorage from 7.2.2.1 to 7.2.2.2

47 of 9721 relevant lines covered (0.48%)

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
    # :reek:FeatureEnvy
27
    def marc_links
×
28
      electronic_access = document['electronic_access_1display']
×
29
      urls = []
×
30
      if electronic_access
×
31
        links_hash = JSON.parse(electronic_access)
×
32
        links_hash.first(2).each do |url, text|
×
33
          description = text[1] ? "#{text[1]}: #{text[0]}" : text[0]
×
34
          urls << { "url" => url, "title" => description }.to_json
×
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(&:to_json)
×
45
    end
×
46
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