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

pulibrary / allsearch_api / dc764cb3-fc9b-47a1-b010-56b68ecb28a7

01 Aug 2025 03:30PM UTC coverage: 99.514%. Remained the same
dc764cb3-fc9b-47a1-b010-56b68ecb28a7

push

circleci

web-flow
Merge pull request #384 from pulibrary/dependabot/bundler/nokogiri-1.18.9

Bump nokogiri from 1.18.8 to 1.18.9

1024 of 1029 relevant lines covered (99.51%)

92.23 hits per line

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

100.0
/app/models/physical_holding.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for determining
4
# the status of a physical holding in the ILS
5
class PhysicalHolding
3✔
6
  def initialize(holding_id:, holding_data:, document_id:)
3✔
7
    @holding_id = holding_id
54✔
8
    @holding_data = holding_data
54✔
9
    @document_id = document_id
54✔
10
  end
11

12
  def barcode
3✔
13
    items&.first&.barcode
43✔
14
  end
15

16
  def call_number
3✔
17
    @holding_data['call_number']
43✔
18
  end
19

20
  def library
3✔
21
    @library ||= @holding_data['library']
91✔
22
  end
23

24
  def status
3✔
25
    return unless library
49✔
26

27
    if coin? || senior_thesis?
49✔
28
      'On-site access'
4✔
29
    elsif alma_temporary_location_status
45✔
30
      alma_temporary_location_status
2✔
31
    elsif alma_location_status
43✔
32
      alma_location_status
27✔
33
    end
34
  end
35

36
  private
3✔
37

38
  attr_accessor :document_id
3✔
39

40
  def alma?
3✔
41
    document_id.start_with?('99') && document_id.end_with?('6421')
117✔
42
  end
43

44
  def coin?
3✔
45
    document_id.start_with? 'coin-'
49✔
46
  end
47

48
  def senior_thesis?
3✔
49
    document_id.start_with? 'dsp'
46✔
50
  end
51

52
  def alma_temporary_location_status
3✔
53
    # temporary location holdings have an alphabetical holding id
54
    return unless alma? && @holding_id.match(/[a-zA-Z]\$[a-zA-Z]/)
47✔
55

56
    @holding_id == 'RES_SHARE$IN_RS_REQ' ? 'Unavailable' : 'View record for Full Availability'
4✔
57
  end
58

59
  def alma_location_status
3✔
60
    return unless alma?
70✔
61

62
    if items_in_place_count == items&.count
54✔
63
      'Available'
48✔
64
    elsif items_in_place_count.zero?
6✔
65
      'Unavailable'
4✔
66
    elsif items_in_place_count < items&.count
2✔
67
      'Some items not available'
2✔
68
    end
69
  end
70

71
  def items
3✔
72
    @items ||= @holding_data['items']&.map { |item| PhysicalItem.new item: } || []
214✔
73
  end
74

75
  def items_in_place_count
3✔
76
    items&.count(&:in_place?)
62✔
77
  end
78
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