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

pulibrary / allsearch_api / ed1cefda-f43b-4b58-95dd-12a33b7f1f7a

02 Jul 2025 06:23PM UTC coverage: 96.252% (-3.2%) from 99.494%
ed1cefda-f43b-4b58-95dd-12a33b7f1f7a

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

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

94 existing lines in 20 files now uncovered.

976 of 1014 relevant lines covered (96.25%)

63.21 hits per line

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

77.27
/app/models/article.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for querying the Summon API, aka "Articles+"
4
class Article
2✔
5
  include ActiveModel::API
2✔
6
  include Parsed
2✔
7
  attr_reader :query_terms, :service
2✔
8

9
  delegate :documents, to: :service_response
2✔
10

11
  def initialize(query_terms:)
2✔
12
    @query_terms = query_terms
15✔
13
    summon_config = Rails.application.config_for(:allsearch)[:summon]
15✔
14
    @service = Summon::Service.new(access_id: summon_config[:access_id],
15✔
15
                                   secret_key: summon_config[:secret_key])
16
  end
17

18
  # For documentation on query parameters, see https://developers.exlibrisgroup.com/summon/apis/SearchAPI/Query/Parameters/
19
  def service_response
2✔
20
    service.search(
46✔
21
      's.q': query_terms, # Lucene-style queries
22
      's.fvf': 'ContentType,Newspaper Article,true', # Excludes newspaper articles
23
      's.ho': 't', # Princeton holdings only
24
      's.dym': 't', # Enables Did You Mean functionality
25
      's.ps': 3 # Limits to three documents in response
26
    )
27
  rescue Summon::Transport::TransportError => error
UNCOV
28
    handle_summon_error(error)
×
29
  end
30

31
  def number
2✔
32
    service_response.record_count
11✔
33
  end
34

35
  def more_link
2✔
UNCOV
36
    URI::HTTPS.build(host: 'princeton.summon.serialssolutions.com', path: '/search',
20✔
37
                     query: service_response.query.query_string)
38
  end
39

40
  private
2✔
41

42
  # :reek:FeatureEnvy
43
  def handle_summon_error(error)
2✔
UNCOV
44
    message = if error.is_a? Summon::Transport::AuthorizationError
×
UNCOV
45
                'Could not authenticate to the upstream Summon service'
×
46
              else
47
                error.message
×
48
              end
UNCOV
49
    raise AllsearchError.new(problem: 'UPSTREAM_ERROR',
×
50
                             msg: message)
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