• 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

13.89
/app/services/electronic_locations_factory.rb
1
# Factory for constructing ElectronicLocation Objects
2
class ElectronicLocationsFactory
1✔
3
  # Construct IIIFManifestURI Objects from Solr Document values
4
  # @param values [Hash] Solr Document values for links Hash by URL
5
  # @return [Array<IIIFManifestURI>]
6
  def self.parse_iiif_manifest_paths(values)
1✔
UNCOV
7
    values.map do |ark_url_key, iiif_manifest_path|
×
UNCOV
8
      ElectronicLocations::IIIFManifestURI.new(ark: ark_url_key, value: iiif_manifest_path)
×
9
    end
10
  end
11

12
  # Construct Holding Objects from Solr Document values
13
  # @param values [Hash] Solr Document values for links Hash by URL
14
  # @return [Array<Holding>]
15
  def self.parse_holdings(values)
1✔
UNCOV
16
    values.map do |holding_id, url_values|
×
UNCOV
17
      url_key = url_values.keys.first
×
UNCOV
18
      ElectronicLocations::Holding.new(id: holding_id, value: url_key)
×
19
    end
20
  end
21

22
  # Generate a Hash indexing the MARC subfield values for an electronic location field
23
  # @param holding_values [Hash] Solr Document values for URL's Hashed by holding ID
24
  # @param values [Hash] Solr Document values for links Hash by URL
25
  # @return [Hash]
26
  def self.parse_subfields(holding_values, values)
1✔
UNCOV
27
    subfields = []
×
UNCOV
28
    holding_values.each do |_holding_id, url_values|
×
UNCOV
29
      url_values.each do |url_key, url_labels|
×
UNCOV
30
        subfield = {}
×
31

UNCOV
32
        url_key = url_values.keys.first
×
UNCOV
33
        subfield[ElectronicLocations::SubfieldCodes::URI] = url_key
×
UNCOV
34
        subfield[ElectronicLocations::SubfieldCodes::LINK_TEXT] = url_labels.first
×
UNCOV
35
        subfield[ElectronicLocations::SubfieldCodes::PUBLIC_NOTE] = url_labels.last if url_labels.length > 1
×
UNCOV
36
        subfields << subfield
×
37
      end
38
    end
39

UNCOV
40
    values.each do |url_key, url_labels|
×
UNCOV
41
      subfield = {}
×
UNCOV
42
      subfield[ElectronicLocations::SubfieldCodes::URI] = url_key
×
UNCOV
43
      subfield[ElectronicLocations::SubfieldCodes::LINK_TEXT] = url_labels.first
×
UNCOV
44
      subfield[ElectronicLocations::SubfieldCodes::PUBLIC_NOTE] = url_labels.last if url_labels.length > 1
×
UNCOV
45
      subfields << subfield
×
46
    end
47

UNCOV
48
    subfields
×
49
  end
50

51
  # Factory method for constructing ElectronicLocation Objects
52
  # @param solr_doc [Hash] Solr Document values
53
  # @return [Array<ElectronicLocation>]
54
  def self.build(solr_doc)
1✔
UNCOV
55
    solr_values = solr_doc.fetch('electronic_access_1display', [])
×
UNCOV
56
    solr_values.map do |values|
×
UNCOV
57
      solr_value = values || '{}'
×
UNCOV
58
      electronic_access_1display = JSON.parse(solr_value)
×
59

UNCOV
60
      iiif_manifest_path_values = electronic_access_1display.delete('iiif_manifest_paths') || {}
×
UNCOV
61
      iiif_manifest_uris = parse_iiif_manifest_paths(iiif_manifest_path_values)
×
62

UNCOV
63
      holding_values = electronic_access_1display.delete('holding_record_856s') || {}
×
UNCOV
64
      holdings = parse_holdings(holding_values)
×
65

UNCOV
66
      subfields = parse_subfields(holding_values, electronic_access_1display)
×
67

UNCOV
68
      ElectronicLocation.new(access_method: ElectronicLocations::Indicators::HTTP,
×
69
                             relationship: ElectronicLocations::Relationships::VERSION,
70
                             subfields:,
71
                             holdings:, iiif_manifest_uris:)
72
    end
73
  end
74
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