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

pulibrary / allsearch_api / abab0c3b-3420-4969-a09f-56494d1bd4a7

05 May 2025 05:52PM UTC coverage: 99.49%. Remained the same
abab0c3b-3420-4969-a09f-56494d1bd4a7

push

circleci

maxkadel
Do not include apostrophes in staff links

Closes #360

0 of 1 new or added line in 1 file covered. (0.0%)

111 existing lines in 21 files now uncovered.

976 of 981 relevant lines covered (99.49%)

101.15 hits per line

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

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

3
# This class is responsible for translating LibraryDatabaseRecords, originally from LibGuides,
4
# into an API response
5
class LibraryDatabase
3✔
6
  include Parsed
3✔
7
  attr_reader :query_terms, :service_response
3✔
8

9
  def initialize(query_terms:)
3✔
10
    @query_terms = query_terms
24✔
11
    @service_response = library_database_service_response
24✔
12
  end
13

14
  def library_database_service_response
3✔
15
    LibraryDatabaseRecord.query(unescaped_terms)
27✔
16
  end
17

18
  def unescaped_terms
3✔
19
    @unescaped_terms ||= URI::DEFAULT_PARSER.unescape(query_terms)
68✔
20
  end
21

22
  # The libguides search does not treat accented characters consistently
23
  # Always use the unaccented version for the "more_link"
24
  def transliterated_escaped_terms
3✔
25
    URI::DEFAULT_PARSER.escape(Normalizer.new(unescaped_terms).without_diacritics)
41✔
26
  end
27

28
  def number
3✔
UNCOV
29
    service_response.count
19✔
30
  end
31

32
  def more_link
3✔
33
    URI::HTTPS.build(host: 'libguides.princeton.edu', path: '/az/databases',
41✔
34
                     query: "q=#{transliterated_escaped_terms}")
35
  end
36

37
  def documents
3✔
UNCOV
38
    service_response.first(3)
19✔
39
  end
40
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