• 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

21.88
/app/controllers/concerns/formatting_concern.rb
1
module FormattingConcern
1✔
2
  extend ActiveSupport::Concern
1✔
3
  # @param records [MARC::Record] Could be one or a collection
4
  # @return [String] A serialized <mrx:record/> or <mrx:collection/>
5
  # "Cleans" the record of invalid xml characters
6
  def records_to_xml_string(records)
1✔
UNCOV
7
    if records.kind_of? Array
×
UNCOV
8
      xml_str = ''
×
UNCOV
9
      StringIO.open(xml_str) do |io|
×
UNCOV
10
        writer = MARC::XMLWriter.new(io)
×
UNCOV
11
        records.each do |r|
×
UNCOV
12
          writer.write(r) unless r.nil?
×
13
        end
UNCOV
14
        writer.close()
×
15
      end
UNCOV
16
      valid_xml(xml_str)
×
UNCOV
17
    elsif records.kind_of? String
×
18
      # example response from /almaws/v1/bibs/{mms_id}/holdings
UNCOV
19
      valid_xml(records)
×
20
    else
UNCOV
21
      valid_xml(records.to_xml.to_s)
×
22
    end
23
  end
24

25
  # Moved from voyager-helpers
26
  # strips invalid xml characters to prevent parsing errors
27
  # only used for "cleaning" individually retrieved records
28
  def valid_xml(xml_string)
1✔
UNCOV
29
    invalid_xml_range = /[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]/
×
UNCOV
30
    xml_string.gsub(invalid_xml_range, '')
×
31
  end
32

33
  # Clean up character encoding problems by passing the
34
  # records through an XML parser
35
  # @param records [MARC::Record] Could be one or a collection
36
  # @return [Hash] If only one record was passed
37
  # @return [Array<Hash>]
38
  def pass_records_through_xml_parser(records)
1✔
39
    reader = MARC::XMLReader.new(StringIO.new(records_to_xml_string(records)))
×
40
    record_hashes = []
×
41
    reader.each { |r| record_hashes << r.to_hash }
×
42
    if record_hashes.length == 1
×
43
      record_hashes.first
×
44
    else
45
      record_hashes
×
46
    end
47
  end
48

49
  def valid_barcode?(barcode)
1✔
UNCOV
50
    (barcode =~ /^(32101[0-9]{9}|PULTST[0-9]{5})$/) == 0
×
51
  end
52

53
  def statuses_to_xml(data)
1✔
54
    # yep!
55
    s = []
×
56
    s << '<statuses>'
×
57
    data.each { |k, v| s << %(<status code="#{k}" label="#{v}" />) }
×
58
    s << '</statuses>'
×
59
    s.join('')
×
60
  end
61
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