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

pulibrary / orangelight / 4c391e0e-519a-40cb-8ad3-354445f4ce03

12 Aug 2025 08:47PM UTC coverage: 85.348% (-10.0%) from 95.335%
4c391e0e-519a-40cb-8ad3-354445f4ce03

push

circleci

web-flow
[#5143] Use access restriction note as Aeon ItemInfo1 if available (#5173)

With this commit, if a user visits a record with an access
restrictions note and presses the Reading Room Request
button, they will get to an Aeon form with the 'Restrictions'
field pre-filled with the restriction note.

If the record does not have an access restrictions note,
the field will be pre-filled with 'Reading Room Access Only',
as it has been previously.

Closes #5143

5493 of 6436 relevant lines covered (85.35%)

251.82 hits per line

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

95.24
/lib/orangelight/string_functions.rb
1
# frozen_string_literal: true
2

3
module StringFunctions
1✔
4
  class << self
1✔
5
    def cn_normalize(str)
1✔
6
      if /^[a-zA-Z]{2,3} \d+([qQ]?)$/.match? str # the normalizer thinks "CD 104" is valid LC
41✔
7
        accession_number(str)&.strip
4✔
8
      else
9
        Lcsort.normalize(str.gsub(/x([A-Z])/, '\1'))&.strip || accession_number(str)&.strip
37✔
10
      end
11
    end
12

13
    def oclc_normalize(oclc, _opts = { prefix: false })
1✔
14
      oclc.gsub(/\D/, '').to_i.to_s
×
15
    end
16

17
    # Needed for name-title browse
18
    # https://github.com/traject/traject/blob/v2.3.1/lib/traject/macros/marc21.rb#L227
19
    def trim_punctuation(str)
1✔
20
      # If something went wrong and we got a nil, just return it
21
      return str unless str
131✔
22

23
      # trailing: comma, slash, semicolon, colon (possibly preceded and followed by whitespace)
24
      str = str.sub(%r{ *[ ,\/;:] *\Z}, '')
131✔
25

26
      # trailing period if it is preceded by at least three letters
27
      # (possibly preceded and followed by whitespace)
28
      str = str.sub(/( *\w\w\w)\. *\Z/, '\1')
131✔
29

30
      # single square bracket characters if they are the start and/or end
31
      #   chars and there are no internal square brackets.
32
      str = str.sub(/\A\[?([^\[\]]+)\]?\Z/, '\1')
131✔
33

34
      # trim any leading or trailing whitespace
35
      str.strip!
131✔
36

37
      str
131✔
38
    end
39

40
    private
1✔
41

42
      def accession_number(str)
1✔
43
        norm = str.upcase
22✔
44
        norm = norm.gsub(/(CD|DVD|LP|LS)-/, '\1') # should file together regardless of dash
22✔
45

46
        # normalize number to 7-digits, ignore oversize q
47
        norm.gsub(/(\d{1,7})(Q$|Q OVERSIZE$)?/) do
22✔
48
          format('%07d', Regexp.last_match[1].to_i)
27✔
49
        end
50
      end
51
  end
52
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