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

pulibrary / allsearch_api / 842726e7-a026-4fa4-95f6-9644d41e6dd0

02 Jul 2025 06:28PM UTC coverage: 99.507% (+0.01%) from 99.494%
842726e7-a026-4fa4-95f6-9644d41e6dd0

Pull #381

circleci

sandbergja
Refactor RackResponseController so that subclasses don't need to implement #json

Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
Pull Request #381: Rewrite DPUL and FindingAids controllers as rack applications

30 of 30 new or added lines in 3 files covered. (100.0%)

81 existing lines in 19 files now uncovered.

1009 of 1014 relevant lines covered (99.51%)

96.77 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✔
UNCOV
10
    @query_terms = query_terms
24✔
UNCOV
11
    @service_response = library_database_service_response
24✔
12
  end
13

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

18
  def unescaped_terms
3✔
UNCOV
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✔
UNCOV
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✔
UNCOV
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