• 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/location_services_component.rb
1
# frozen_string_literal: true
2
# This component is responsible for showing the user
3
# which services are available for a holding, given
4
# its location (typically some type of Request button)
5
# :reek:TooManyMethods
6
# :reek:TooManyInstanceVariables
7
class Holdings::LocationServicesComponent < ViewComponent::Base
×
8
  def initialize(adapter, holding_id, location_rules, holding, open_holdings = nil)
×
9
    @adapter = adapter
×
10
    @holding_id = holding_id
×
11
    @location_rules = location_rules
×
12
    @holding = holding
×
13
    @open_holdings = open_holdings
×
14
  end
×
15

16
    private
×
17

18
      attr_reader :adapter, :holding_id, :location_rules, :holding, :open_holdings
×
19

20
      def doc_id
×
21
        holding["mms_id"] || adapter.doc_id
×
22
      end
×
23

24
      def holding_object
×
25
        Requests::Holding.new(mfhd_id: holding_id, holding_data: holding)
×
26
      end
×
27

28
      # rubocop:disable Lint/DuplicateBranch
29
      # :reek:TooManyStatements
30
      def button_component
×
31
        if holding_id == 'thesis' || numismatics?
×
32
          AeonRequestButtonComponent.new(document:, holding: holding_hash, url_class: Requests::NonAlmaAeonUrl)
×
33
        elsif items && items.length > 1
×
34
          RequestButtonComponent.new(doc_id:, holding_id:, location: location_rules, open_holdings:)
×
35
        elsif aeon_location?
×
36
          AeonRequestButtonComponent.new(document:, holding: holding_hash)
×
37
        elsif scsb_location?
×
38
          RequestButtonComponent.new(doc_id:, location: location_rules, holding:, open_holdings:)
×
39
        elsif temporary_holding_id?
×
40
          holding_identifier = temporary_location_holding_id_first
×
41
          RequestButtonComponent.new(doc_id:, holding_id: holding_identifier, location: location_rules, open_holdings:)
×
42
        else
×
43
          RequestButtonComponent.new(doc_id:, holding_id:, location: location_rules, open_holdings:)
×
44
        end
×
45
      end
×
46
      # rubocop:enable Lint/DuplicateBranch
47

48
      def show_request
×
49
        if (requestable? && !thesis?) || numismatics?
×
50
          'service-always-requestable'
×
51
        else
×
52
          'service-conditional'
×
53
        end
×
54
      end
×
55

56
      def requestable?
×
57
        !adapter.alma_holding?(holding_id) || aeon_location? || scsb_location?
×
58
      end
×
59

60
      def open_location?
×
61
        location_rules && location_rules[:open]
×
62
      end
×
63

64
      def aeon_location?
×
65
        location_rules && location_rules[:aeon_location]
×
66
      end
×
67

68
      def requestable_location?
×
69
        return false if adapter.sc_location_with_suppressed_button?(holding)
×
70
        return false if adapter.unavailable_holding?(holding)
×
71
        location_rules && location_rules[:requestable]
×
72
      end
×
73

74
      def numismatics?
×
75
        holding_id == 'numismatics'
×
76
      end
×
77

78
      def thesis?
×
79
        holding_id == 'thesis' && adapter.pub_date > 2012
×
80
      end
×
81

82
      def scsb_location?
×
83
        location_rules && /^scsb.+/ =~ location_rules['code']
×
84
      end
×
85

86
      # Example of a temporary holding, in this case holding_id is : firestone$res3hr
87
      # {\"firestone$res3hr\":{\"location_code\":\"firestone$res3hr\",
88
      # \"current_location\":\"Circulation Desk (3 Hour Reserve)\",\"current_library\":\"Firestone Library\",
89
      # \"call_number\":\"HT1077 .M87\",\"call_number_browse\":\"HT1077 .M87\",
90
      # \"items\":[{\"holding_id\":\"22740601020006421\",\"id\":\"23740600990006421\",
91
      # \"status_at_load\":\"1\",\"barcode\":\"32101005621469\",\"copy_number\":\"1\"}]}}
92
      def temporary_holding_id?
×
93
        /[a-zA-Z]\$[a-zA-Z]/.match?(holding_id)
×
94
      end
×
95

96
      # When it is a temporary location and is requestable, use the first holding_id of this temporary location items.
97
      def temporary_location_holding_id_first
×
98
        holding["items"][0]["holding_id"]
×
99
      end
×
100

101
      def document
×
102
        adapter.document
×
103
      end
×
104

105
      # The full holding hash, with the holding_id as the key
106
      def holding_hash
×
107
        holding_object.to_h
×
108
      end
×
109

110
      def items
×
111
        holding['items']
×
112
      end
×
113
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