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

pulibrary / allsearch_api / dc764cb3-fc9b-47a1-b010-56b68ecb28a7

01 Aug 2025 03:30PM UTC coverage: 99.514%. Remained the same
dc764cb3-fc9b-47a1-b010-56b68ecb28a7

push

circleci

web-flow
Merge pull request #384 from pulibrary/dependabot/bundler/nokogiri-1.18.9

Bump nokogiri from 1.18.8 to 1.18.9

1024 of 1029 relevant lines covered (99.51%)

92.23 hits per line

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

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

3
# This class is responsible for querying the Art Museum API
4
class ArtMuseum
3✔
5
  include ActiveModel::API
3✔
6
  include Parsed
3✔
7
  attr_reader :service, :service_response
3✔
8

9
  def initialize(query_terms:)
3✔
10
    @query_terms = query_terms
16✔
11
    @service = 'artmuseum'
16✔
12
    @service_response = art_museum_service_response
16✔
13
  end
14

15
  def query_terms
3✔
16
    @query_terms.truncate(220, omission: '', separator: /\s/)
47✔
17
  end
18

19
  private
3✔
20

21
  def art_museum_service_response
3✔
22
    uri = URI::HTTPS.build(host: 'data.artmuseum.princeton.edu', path: '/search',
16✔
23
                           query: "q=#{query_terms}&type=all&size=3")
24
    response = Net::HTTP.get(uri)
16✔
25
    begin
26
      JSON.parse(response, symbolize_names: true)
16✔
27
    rescue JSON::ParserError
28
      handle_parser_error response
1✔
29
    end
30
  end
31

32
  def number
3✔
33
    service_response.dig(:hits, :total)
14✔
34
  end
35

36
  def more_link
3✔
37
    URI::HTTPS.build(host: 'artmuseum.princeton.edu', path: '/search/collections',
28✔
38
                     query: "mainSearch=\"#{query_terms}\"")
39
  end
40

41
  def documents
3✔
42
    @documents ||= service_response.dig(:hits, :hits)
14✔
43
  end
44

45
  def handle_parser_error(response)
3✔
46
    raise AllsearchError.new(
1✔
47
      problem: 'UPSTREAM_ERROR',
48
      msg: "Query to upstream failed with #{ActionController::Base.helpers.strip_tags(response)}"
49
    )
50
  end
51
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