• 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

93.1
/app/adapters/alma_adapter/marc_record.rb
1
class AlmaAdapter
1✔
2
  # Adds functionality to an Alma::Bib to handle the various ways we manipulate
3
  # or access the MARC data for an individual record.
4
  class MarcRecord < SimpleDelegator
1✔
5
    attr_reader :bib, :marc_record
1✔
6

7
    # @param bib [Alma::Bib]
8
    # @param marc_record [MARC::Record]
9
    # @note We accept these two separately because parsing a bunch of MARC
10
    # records at once is more performant than doing one at a time, so it's
11
    # done before initializing this.
12
    def initialize(bib, marc_record)
1✔
13
      super(marc_record)
16✔
14
      @marc_record = marc_record
16✔
15
      @bib = bib
16✔
16
    end
17

18
    def suppressed?
1✔
NEW
19
      bib['suppress_from_publishing'] == 'true'
×
20
    end
21

22
    def linked_record_ids
1✔
23
      linked_record_fields = marc_record.fields('774').select do |field|
5✔
24
        alma_bib_id?(field['w']) && field['t']
4✔
25
      end
26
      linked_record_fields.map do |field|
5✔
27
        field['w']
4✔
28
      end
29
    end
30

31
    def enrich_with_item(item)
1✔
32
      item = ::AlmaAdapter::AlmaItem.new(item)
5✔
33
      marc_record.append(item.enrichment_876)
5✔
34
    end
35

36
    # Remove source record 852s and 86Xs, to reduce confusion when holding
37
    # data is added.
38
    def delete_conflicting_holding_data!
1✔
39
      marc_record.fields.delete_if { |f| %w[852 866 867 868].include? f.tag }
170✔
40
    end
41

42
    # Remove source record 876s. These probably come from a publishing job, and
43
    # if we're calling this they're probably getting added back via
44
    # enrich_with_item to enable further processing.
45
    def delete_conflicting_item_data!
1✔
46
      marc_record.fields.delete_if { |f| ['876'].include? f.tag }
×
47
    end
48

49
    # @param holding [Alma::BibHolding | AlmaAdapter::AlmaHolding] Either a
50
    #   holding from the API or an already built `AlmaAdapter::AlmaHolding`. The
51
    #   holding may already be built in the case of
52
    #   `AlmaAdapter::ScsbDumpRecord`
53
    def enrich_with_holding(holding, recap: false)
1✔
54
      holding = ::AlmaAdapter::AlmaHolding.for(holding, recap:) unless holding.respond_to?(:marc_record_enrichment)
5✔
55
      marc_record.fields.concat(holding.marc_record_enrichment)
5✔
56
    end
57

58
    # Strips non-numeric tags for ReCAP, whose parser can't handle them.
59
    def strip_non_numeric!
1✔
60
      marc_record.fields.delete_if do |field|
6✔
61
        # tag with non numeric character
62
        field.tag.scan(/^(\s|\D+)/).present?
202✔
63
      end
64
    end
65

66
    # Pass a specific field code to check if it is an alma id.
67
    def alma_bib_id?(code)
1✔
68
      code.to_s.start_with?('99') && code.to_s.end_with?('06421')
4✔
69
    end
70
  end
71
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