• 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/models/requests/location.rb
1
# frozen_string_literal: true
2
module Requests
×
3
  # This class is responsible for answering questions about
4
  # a location, based on data supplied from a bibdata hash
5
  class Location
×
6
    # @param bibdata_location [Hash] The hash for a bibdata holding (https://bibdata.princeton.edu/locations/holding_locations)
7
    def initialize(bibdata_location)
×
8
      @bibdata_location = bibdata_location.to_h.with_indifferent_access
×
9
    end
×
10

11
    def code
×
12
      return nil if bibdata_location.blank?
×
13
      bibdata_location['code']
×
14
    end
×
15

16
    def short_label
×
17
      bibdata_location["label"]
×
18
    end
×
19

20
    def location_label
×
21
      return nil unless library_data_present?
×
22
      label = library_label
×
23
      label += " - #{short_label}" if short_label.present?
×
24
      label
×
25
    end
×
26

27
    def library_code
×
28
      bibdata_location.dig('library', 'code')
×
29
    end
×
30

31
    def library_label
×
32
      bibdata_location.dig('library', 'label')
×
33
    end
×
34

35
    def valid?
×
36
      bibdata_location.key?(:library) && bibdata_location[:library].key?(:code)
×
37
    end
×
38

39
    def aeon?
×
40
      bibdata_location[:aeon_location] == true
×
41
    end
×
42

43
    def annex?
×
44
      valid? && library_code == 'annex'
×
45
    end
×
46

47
    def circulates?
×
48
      bibdata_location[:circulates] == true
×
49
    end
×
50

51
    def always_requestable?
×
52
      bibdata_location[:always_requestable] == true
×
53
    end
×
54

55
    def holding_library
×
56
      bibdata_location[:holding_library]
×
57
    end
×
58

59
    def delivery_locations
×
60
      bibdata_location[:delivery_locations] || []
×
61
    end
×
62

63
    def to_h
×
64
      bibdata_location
×
65
    end
×
66

67
    def recap?
×
68
      bibdata_location[:remote_storage] == "recap_rmt"
×
69
    end
×
70

71
    ## Accepts an array of location hashes and sorts them according to our quirks
72
    def sort_pick_ups
×
73
      # staff only locations go at the bottom of the list and Firestone to the top
74

75
      public_delivery_locations = delivery_locations.select { |loc| loc[:staff_only] == false }
×
76
      public_delivery_locations.sort_by! { |loc| loc[:label] }
×
77

78
      firestone = public_delivery_locations.find { |loc| loc[:label] == "Firestone Library" }
×
79
      public_delivery_locations.insert(0, public_delivery_locations.delete_at(public_delivery_locations.index(firestone))) unless firestone.nil?
×
80

81
      staff_delivery_locations = delivery_locations.select { |loc| loc[:staff_only] == true }
×
82
      staff_delivery_locations.sort_by! { |loc| loc[:label] }
×
83

84
      staff_delivery_locations.each do |loc|
×
85
        loc[:label] = loc[:label] + " (Staff Only)"
×
86
      end
×
87
      public_delivery_locations + staff_delivery_locations
×
88
    end
×
89

90
    def build_delivery_locations
×
91
      delivery_locations.map do |loc|
×
92
        library = loc["library"]
×
93
        pick_up_code = library.present? && library["code"]
×
94
        pick_up_code ||= 'firestone'
×
95
        loc.merge("pick_up_location_code" => pick_up_code) { |_key, v1, _v2| v1 }
×
96
      end
×
97
    end
×
98

99
      private
×
100

101
        def library_data_present?
×
102
          bibdata_location["library"].present?
×
103
        end
×
104

105
        attr_reader :bibdata_location
×
106
  end
×
107
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