• 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/stackmap_service.rb
1
# frozen_string_literal: true
2

UNCOV
3
class StackmapService
×
4
  # A url to the stackmap for the bib record
UNCOV
5
  class Url
×
6
    # Constructor
7
    # @param document [SolrDocument] Solr document for bib record
8
    # @param loc [String] Bib record location code
9
    # @param cn [String] optional provided call number
UNCOV
10
    def initialize(document:, loc:, cn: nil)
×
UNCOV
11
      @document = document
×
UNCOV
12
      @loc = loc
×
UNCOV
13
      @cn = cn
×
UNCOV
14
    end
×
15

16
    # Return the correct stackmap url ased on the location information of the bib record
17
    # @return [String] stackmap url
UNCOV
18
    def url
×
UNCOV
19
      if valid?
×
UNCOV
20
        if StackmapService::Url.missing_stackmap_reserves.include? @loc
×
UNCOV
21
          StackmapService::Url.missing_stackmap_reserves[@loc]
×
UNCOV
22
        elsif stackmap_libs.include? lib
×
UNCOV
23
          stackmap_url
×
UNCOV
24
        else
×
25
          fallback_url
×
UNCOV
26
        end
×
UNCOV
27
      else
×
UNCOV
28
        fallback_url
×
UNCOV
29
      end
×
UNCOV
30
    end
×
31

UNCOV
32
    def preferred_callno
×
UNCOV
33
      if by_title_locations.include? @loc
×
UNCOV
34
        @document['title_display']
×
UNCOV
35
      else
×
UNCOV
36
        @cn || @document['call_number_browse_s']&.first
×
UNCOV
37
      end
×
UNCOV
38
    end
×
39

UNCOV
40
    def location_label
×
UNCOV
41
      return nil if holding_location.nil?
×
UNCOV
42
      holding_location[:label].presence || holding_location[:library][:label]
×
UNCOV
43
    end
×
44

UNCOV
45
    def self.missing_stackmap_reserves
×
UNCOV
46
      {
×
UNCOV
47
        'arch$res3hr' => 'https://library.princeton.edu/architecture',
×
UNCOV
48
        'stokes$respiapr' => 'https://library.princeton.edu/stokes',
×
UNCOV
49
        'plasma$res' => 'https://library.princeton.edu/plasma-physics',
×
UNCOV
50
        'lewis$gr' => 'https://library.princeton.edu/lewis'
×
UNCOV
51
      }
×
UNCOV
52
    end
×
53

UNCOV
54
    private
×
55

UNCOV
56
      def stackmap_url
×
UNCOV
57
        stackmap_url = 'https://princeton.stackmap.com/view/'
×
UNCOV
58
        stackmap_params = {
×
UNCOV
59
          callno:,
×
UNCOV
60
          location: @loc,
×
UNCOV
61
          library: holding_location[:library][:label]
×
UNCOV
62
        }
×
UNCOV
63
        "#{stackmap_url}?#{stackmap_params.to_query}"
×
UNCOV
64
      end
×
65

66
      # redirects to catalog record page if location or call number is missing_stackmap_reserves
67
      # takes user to catalog home page if @document (bibid) is missing
UNCOV
68
      def fallback_url
×
UNCOV
69
        "/catalog/#{@document.to_param}"
×
UNCOV
70
      end
×
71

UNCOV
72
      def bibid
×
73
        @bibid ||= @document[:id]
×
UNCOV
74
      end
×
75

76
      # use the optionally provided call number unless if by title location
UNCOV
77
      def callno
×
UNCOV
78
        @cn = preferred_callno
×
UNCOV
79
      end
×
80

UNCOV
81
      def stackmap_libs
×
UNCOV
82
        %w[arch eastasian engineer lewis mendel stokes firestone]
×
UNCOV
83
      end
×
84

UNCOV
85
      def by_title_locations
×
UNCOV
86
        %w[lewis$serial plasma$ps stokes$sprps stokes$spiaps]
×
UNCOV
87
      end
×
88

UNCOV
89
      def holding_location
×
UNCOV
90
        @holding_location ||= Bibdata.holding_locations[@loc]
×
UNCOV
91
      end
×
92

UNCOV
93
      def lib
×
UNCOV
94
        @lib ||= holding_location[:library][:code]
×
UNCOV
95
      end
×
96

UNCOV
97
      def valid?
×
UNCOV
98
        !holding_location.nil? && !@document.nil? && !callno.nil?
×
UNCOV
99
      end
×
UNCOV
100
  end
×
UNCOV
101
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

© 2026 Coveralls, Inc