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

pulibrary / bibdata / 1dcebae2-3318-4e77-bc53-82276e293354

02 May 2025 04:45PM UTC coverage: 28.256% (-63.9%) from 92.189%
1dcebae2-3318-4e77-bc53-82276e293354

push

circleci

sandbergja
Add basic infrastructure for compiling rust code

* Add a rake compile task to compile
* Run the rake task in CI
* Run the rake task before rspec tests with the rust tag, to provide quick feedback on rust changes in TDD cycles

2 of 7 new or added lines in 2 files covered. (28.57%)

2467 existing lines in 97 files now uncovered.

1089 of 3854 relevant lines covered (28.26%)

0.29 hits per line

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

0.0
/app/adapters/alma_adapter/marc_record.rb
UNCOV
1
class AlmaAdapter
×
2
  # Adds functionality to an Alma::Bib to handle the various ways we manipulate
3
  # or access the MARC data for an individual record.
UNCOV
4
  class MarcRecord < SimpleDelegator
×
UNCOV
5
    attr_reader :bib, :marc_record
×
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.
UNCOV
12
    def initialize(bib, marc_record)
×
UNCOV
13
      super(marc_record)
×
UNCOV
14
      @marc_record = marc_record
×
UNCOV
15
      @bib = bib
×
UNCOV
16
    end
×
17

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

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

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

36
    # Remove source record 852s and 86Xs, to reduce confusion when holding
37
    # data is added.
UNCOV
38
    def delete_conflicting_holding_data!
×
UNCOV
39
      marc_record.fields.delete_if { |f| %w[852 866 867 868].include? f.tag }
×
UNCOV
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.
UNCOV
45
    def delete_conflicting_item_data!
×
46
      marc_record.fields.delete_if { |f| ['876'].include? f.tag }
×
UNCOV
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`
UNCOV
53
    def enrich_with_holding(holding, recap: false)
×
UNCOV
54
      holding = ::AlmaAdapter::AlmaHolding.for(holding, recap:) unless holding.respond_to?(:marc_record_enrichment)
×
UNCOV
55
      marc_record.fields.concat(holding.marc_record_enrichment)
×
UNCOV
56
    end
×
57

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

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