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

pulibrary / bibdata / 2ee2c4fc-5ef0-4806-b86e-01bf70aa67a0

24 Dec 2024 04:55PM UTC coverage: 91.859% (-0.04%) from 91.902%
2ee2c4fc-5ef0-4806-b86e-01bf70aa67a0

Pull #2569

circleci

christinach
Generate new .rubocop_todo.yml
rubocop fix
Pull Request #2569: Rubocop gems

335 of 378 new or added lines in 57 files covered. (88.62%)

2 existing lines in 2 files now uncovered.

3385 of 3685 relevant lines covered (91.86%)

377.92 hits per line

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

79.49
/app/controllers/barcode_controller.rb
1
class BarcodeController < ApplicationController
1✔
2
  include FormattingConcern
1✔
3

4
  def index
1✔
5
    if params[:barcode]
1✔
6
      redirect_to action: :barcode, barcode: sanitized_barcode, status: :moved_permanently
×
7
    else
8
      render plain: 'Please supply a barcode.', status: :not_found
1✔
9
    end
10
  end
11

12
  # Client: This endpoint is used by the ReCAP inventory management system, LAS,
13
  #   to pull data from our ILS when items are accessioned
14
  def scsb
1✔
15
    barcode = params[:barcode]
7✔
16
    if valid_barcode?(barcode)
7✔
17
      adapter = AlmaAdapter.new
7✔
18
      item = adapter.item_by_barcode(barcode)
7✔
19
      mms_id = item['bib_data']['mms_id']
5✔
20
      record = adapter.get_bib_record(mms_id, show_suppressed: true)
5✔
21

22
      # If the bib record is not found, the returned record will be nil and the controller should return with a 404 status
23
      if record.nil?
5✔
24
        render plain: "Record #{mms_id} not found", status: :not_found
×
25
        return
×
26
      end
27
      holding = adapter.holding_by_id(mms_id:, holding_id: item.holding_data['holding_id'])
5✔
28
      records = if record.linked_record_ids.present?
4✔
29
                  adapter.get_bib_records(record.linked_record_ids)
1✔
30
                else
31
                  [record]
3✔
32
                end
33
      records.each do |bib_record|
4✔
34
        bib_record.enrich_with_item(item)
5✔
35
        bib_record.delete_conflicting_holding_data!
5✔
36
        bib_record.enrich_with_holding(holding, recap: true)
5✔
37
        bib_record.strip_non_numeric!
5✔
38
      end
39
      if records == []
4✔
40
        render plain: "Barcode #{barcode} not found.", status: :not_found
×
41
      else
42
        respond_to do |wants|
4✔
43
          wants.json  do
4✔
44
            json = MultiJson.dump(pass_records_through_xml_parser(records))
×
45
            render json:
×
46
          end
47
          wants.xml do
4✔
48
            xml = records_to_xml_string(records)
4✔
49
            render xml:
4✔
50
          end
51
        end
52
      end
53
    else
NEW
54
      render plain: "Barcode #{barcode} not valid.", status: :not_found
×
55
    end
56
  rescue StandardError => e
57
    handle_alma_exception(exception: e, message: "Error for barcode: #{barcode}")
3✔
58
  end
59

60
  private
1✔
61

62
    def sanitized_barcode
1✔
63
      CGI.escape(params[:barcode])
×
64
    end
65
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