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

pulibrary / orangelight / 0e37073d-109c-440c-949f-49d2aa86311b

18 Aug 2025 09:05PM UTC coverage: 0.482% (-94.9%) from 95.343%
0e37073d-109c-440c-949f-49d2aa86311b

push

circleci

web-flow
Replace per_page_options_for_select with custom component to avoid deprecation issue (#5186)

* Start creating new component to address deprecaton warning

* Replace per_page_options_for_select with custom component to avoid deprecation issue

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

---------

Co-authored-by: Ryan Jensen <rj1044@princeton.edu>
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

0 of 33 new or added lines in 1 file covered. (0.0%)

9374 existing lines in 213 files now uncovered.

47 of 9753 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/services/holding_requests_adapter.rb
1
# frozen_string_literal: false
2

3
# Adapter for SolrDocument instances and the Bibdata Class
UNCOV
4
class HoldingRequestsAdapter
×
UNCOV
5
  attr_reader :document
×
6

7
  # Construct the interface for the Solr Document and Bib. Data API
8
  # @param document [SolrDocument]
9
  # @param bib_data_service [Class] Class or singleton used for the bibliographic data service
UNCOV
10
  def initialize(document, bib_data_service)
×
UNCOV
11
    @document = document
×
UNCOV
12
    @bib_data_service = bib_data_service
×
UNCOV
13
  end
×
14

15
  # Retrieve the ID for the Solr Document
16
  # @return [String] the ID value
UNCOV
17
  def doc_id
×
UNCOV
18
    @document.fetch('id')
×
UNCOV
19
  end
×
20

21
  # Access the holding locations from Bib. Data
22
  # @return [Hash] location hash structure
UNCOV
23
  delegate :holding_locations, to: :@bib_data_service
×
24

25
  # Retrieve the holdings information from the Solr Document
26
  # @return [Hash] holdings values
UNCOV
27
  def doc_holdings
×
UNCOV
28
    @document.holdings_all_display
×
UNCOV
29
  rescue StandardError => error
×
UNCOV
30
    Rails.logger.warn error
×
UNCOV
31
    {}
×
UNCOV
32
  end
×
33

34
  # Retrieve the electronic access information
35
  # @return [String] electronic access value
UNCOV
36
  delegate :doc_electronic_access, to: :@document
×
37

38
  # Parse IIIF Manifest links from the electronic access information
39
  # @return [Hash] IIIF Manifests information
UNCOV
40
  delegate :iiif_manifests, to: :@document
×
41

42
  # Retrieve the electronic portfolio information
43
  # @return [String] electronic portfolio values
UNCOV
44
  delegate :electronic_portfolios, to: :@document
×
UNCOV
45
  delegate :sibling_electronic_portfolios, to: :@document
×
46

47
  # Retrieve only the ELF holding records
48
  # @return [Hash] ELF holding information
UNCOV
49
  def doc_holdings_elf
×
UNCOV
50
    doc_holdings.select do |_id, h|
×
UNCOV
51
      h.key?('location_code') && h['location_code'].start_with?('elf')
×
UNCOV
52
    end
×
UNCOV
53
  end
×
54

55
  # Retrieve only the records for physical holdings
56
  # @return [Hash] physical holding information
UNCOV
57
  def doc_holdings_physical
×
UNCOV
58
    doc_holdings.select do |_id, h|
×
UNCOV
59
      h.key?('location_code') && !h['location_code'].start_with?('elf')
×
UNCOV
60
    end
×
UNCOV
61
  end
×
UNCOV
62
  alias physical_holdings doc_holdings_physical
×
63

64
  # Retrieve the physical holdings records grouped by Library and Location
65
  # Returns an array of Requests::HoldingGroup objects
UNCOV
66
  def grouped_physical_holdings
×
UNCOV
67
    doc_holdings_physical
×
UNCOV
68
      .map { |id, data| Requests::Holding.new(mfhd_id: id, holding_data: data) }
×
UNCOV
69
      .group_by(&:full_location_name)
×
UNCOV
70
      .map { |group_name, holdings| Requests::HoldingGroup.new(group_name:, holdings:) }
×
UNCOV
71
      .sort
×
UNCOV
72
  end
×
73

74
  # Retrieve the restrictions placed upon physical holdings
75
  # @return [Array<String>]
UNCOV
76
  def restrictions
×
UNCOV
77
    doc_holdings_physical.each_value.map { |holding| restrictions_for_holding(holding) }
×
UNCOV
78
                         .flatten.compact.uniq
×
UNCOV
79
  end
×
80

81
  # Determine whether or not the catalog record is for a periodical
82
  # @return [TrueClass, FalseClass]
UNCOV
83
  def journal?
×
UNCOV
84
    @document.fetch('format', []).include?('Journal')
×
UNCOV
85
  end
×
86

87
  # Retrieve the publication date for the catalog record
88
  # @return [String] the date value
UNCOV
89
  def pub_date
×
UNCOV
90
    @document.key?('pub_date_start_sort') ? @document['pub_date_start_sort'] : 0
×
UNCOV
91
  end
×
92

93
  # Methods for holding values
94
  # Should these be refactored into static methods
95
  # (or should a decorator be used for holding values?)
96

97
  # Retrieve the location rules from holding values
98
  # @param holding [Hash] the holding values
99
  # @return [Hash] location values
UNCOV
100
  def holding_location_rules(holding)
×
UNCOV
101
    loc_code = holding.fetch('location_code', nil)
×
UNCOV
102
    return loc_code if loc_code.nil?
×
UNCOV
103
    @bib_data_service.holding_locations[loc_code.to_sym]
×
UNCOV
104
  end
×
105

UNCOV
106
  def temp_location_code(holding)
×
UNCOV
107
    holding['temp_location_code']
×
UNCOV
108
  end
×
109

110
  # Retrieve the call number from holding values
111
  # @param holding [Hash] the holding values
112
  # @return [String] the call number
UNCOV
113
  def call_number(holding)
×
UNCOV
114
    holding['call_number_browse'] || holding['call_number']
×
UNCOV
115
  end
×
116

117
  # Determine whether or not the holding is for a repository item
118
  # @return [TrueClass, FalseClass]
UNCOV
119
  def repository_holding?(holding)
×
UNCOV
120
    holding['dspace'] || holding['location_code'] == 'rare$num'
×
UNCOV
121
  end
×
122

UNCOV
123
  def sc_location_with_suppressed_button?(holding)
×
UNCOV
124
    additional_locations = ["rare$xmr", "mudd$scamudd", "rare$xrr", "rare$xgr", "rare$xcr", "mudd$phr"]
×
UNCOV
125
    holding['location_code'].start_with?('rare$sca') || additional_locations.include?(holding['location_code'])
×
UNCOV
126
  end
×
127

128
  # Determine whether or not the holding is for a SCSB items with ReCAP
129
  # @return [TrueClass, FalseClass]
UNCOV
130
  def scsb_holding?(holding)
×
UNCOV
131
    /^scsb.+/ =~ holding['location_code']
×
UNCOV
132
  end
×
133

134
  # Determine whether or not the holding has no child items
135
  # @return [TrueClass, FalseClass]
UNCOV
136
  def empty_holding?(holding)
×
UNCOV
137
    holding['items'].nil?
×
UNCOV
138
  end
×
139

140
  # Retrieve the restrictions for a given holding
141
  # Duplicates PhysicalHoldingsMarkupBuilder.scsb_list
142
  # @param holding [Hash]
UNCOV
143
  def restrictions_for_holding(holding)
×
UNCOV
144
    return [] unless holding.key? 'items'
×
UNCOV
145
    holding['items'].map { |values| values['use_statement'] }.compact_blank
×
UNCOV
146
  end
×
147

148
  # Determine whether or not the holding is explicitly marked as "Unavailable"
149
  # @return [TrueClass, FalseClass]
UNCOV
150
  def unavailable_holding?(holding)
×
UNCOV
151
    holding['dspace'] == false
×
UNCOV
152
  end
×
153

154
  # Determine whether or not the holding has a shelving title
155
  # @return [TrueClass, FalseClass]
UNCOV
156
  def shelving_title?(holding)
×
UNCOV
157
    !holding['shelving_title'].nil?
×
UNCOV
158
  end
×
159

160
  # Determine whether or not the holding has a location note
161
  # @return [TrueClass, FalseClass]
UNCOV
162
  def location_note?(holding)
×
UNCOV
163
    !holding['location_note'].nil?
×
UNCOV
164
  end
×
165

166
  # Determine whether or not the holding features a location
167
  # @return [TrueClass, FalseClass]
UNCOV
168
  def location_has?(holding)
×
UNCOV
169
    !holding['location_has'].nil?
×
UNCOV
170
  end
×
171

172
  # Determine whether or not the holding features a supplements note
173
  # @return [TrueClass, FalseClass]
UNCOV
174
  def supplements?(holding)
×
UNCOV
175
    holding['supplements']&.compact.present?
×
UNCOV
176
  end
×
177

178
  # Determine whether or not the holding features an index note
179
  # @return [TrueClass, FalseClass]
UNCOV
180
  def indexes?(holding)
×
UNCOV
181
    holding['indexes']&.compact.present?
×
UNCOV
182
  end
×
183

184
  # Determine whether or not the holding is for an Alma holding
185
  # @return [TrueClass, FalseClass]
UNCOV
186
  def alma_holding?(holding_id)
×
UNCOV
187
    return false if @document.fetch(:id, '').start_with?('SCSB')
×
UNCOV
188
    return false if %w[thesis numismatics visuals].include? holding_id
×
UNCOV
189
    true
×
UNCOV
190
  end
×
UNCOV
191
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