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

pulibrary / allsearch_api / 29cc47ba-38a5-447a-9a89-fa55bc36f401

14 Oct 2025 01:59PM UTC coverage: 99.32% (-0.2%) from 99.514%
29cc47ba-38a5-447a-9a89-fa55bc36f401

Pull #395

circleci

sandbergja
add missing require_relative
Pull Request #395: Migrate a few more controllers away from Rails

8 of 8 new or added lines in 4 files covered. (100.0%)

90 existing lines in 18 files now uncovered.

1022 of 1029 relevant lines covered (99.32%)

96.72 hits per line

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

95.45
/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
3✔
5
  include ActiveModel::API
3✔
6
  include Parsed
3✔
7
  attr_reader :query_terms, :service
3✔
8

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

11
  def initialize(query_terms:)
3✔
12
    @query_terms = query_terms
21✔
13
    summon_config = Rails.application.config_for(:allsearch)[:summon]
21✔
14
    @service = Summon::Service.new(access_id: summon_config[:access_id],
21✔
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
3✔
20
    service.search(
61✔
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)
1✔
29
  end
30

31
  def number
3✔
32
    service_response.record_count
15✔
33
  end
34

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

40
  private
3✔
41

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