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

pulibrary / bibdata / 373ad6ff-fad2-405a-ab26-3d30fb5ceecf

24 Dec 2024 08:24PM UTC coverage: 91.938% (+0.08%) from 91.859%
373ad6ff-fad2-405a-ab26-3d30fb5ceecf

Pull #2563

circleci

maxkadel
Put attaching xml files in their own batch
Pull Request #2563: I2321 Shift SCSB full index tasks into separate background jobs

152 of 156 new or added lines in 10 files covered. (97.44%)

65 existing lines in 17 files now uncovered.

3478 of 3783 relevant lines covered (91.94%)

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

17
    def suppressed?
1✔
UNCOV
18
      bib["suppress_from_publishing"] == "true"
×
19
    end
20

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

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

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

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

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

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

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