• 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

91.3
/app/models/electronic_location.rb
1
# Model for electronic location (MARC 856) fields
2
# @see https://www.loc.gov/marc/bibliographic/bd856.html
3
class ElectronicLocation
1✔
4
  # Constructor
5
  # @param access_method [String] code for the access method
6
  # @param relationship [String] code for the relationship
7
  # @param subfields [Array<Hash>] subfield Hashes
8
  # @param holdings [Array<Holding>] holding values
9
  # @param iiif_manifest_uris [Array<IIIFManifestURI>] IIIF manifests
10
  def initialize(access_method:, relationship:, subfields:, holdings:, iiif_manifest_uris:)
1✔
11
    @access_method = access_method
2✔
12
    @relationship = relationship
2✔
13
    @subfields = subfields
2✔
14
    index_holdings!(holdings)
2✔
15
    @manifests = iiif_manifest_uris.map(&:to_s)
2✔
16
    @iiif_manifest_uris = iiif_manifest_uris
2✔
17
  end
18

19
  # Returns the subfield value containing an ARK URL
20
  # @return [Array<String>] the ARK URLs
21
  def identifiers
1✔
22
    iiif_manifest_arks + @subfields.select do |subfield|
1✔
23
      subfield.key?(ElectronicLocations::SubfieldCodes::URI) && /arks\.princeton\.edu/.match(subfield[ElectronicLocations::SubfieldCodes::URI])
1✔
24
    end.map { |subfield| subfield[ElectronicLocations::SubfieldCodes::URI] }
1✔
25
  end
26

27
  def uri
1✔
NEW
28
    @subfields.flat_map { |x| x['u'] }.compact.first
×
29
  end
30

31
  def label
1✔
NEW
32
    @subfields.flat_map { |x| x['y'] }.compact.first || uri
×
33
  end
34

35
  private
1✔
36

37
    def iiif_manifest_arks
1✔
38
      @iiif_manifest_arks ||= @iiif_manifest_uris.map(&:ark).map(&:to_s)
1✔
39
    end
40

41
    # Index the electronic locations by labels
42
    # @param holdings [Holding] an array of electronic holdings
43
    # @param [Hash] Hash of Holdings indexed by their identifiers
44
    def index_holdings!(holdings)
1✔
45
      @holdings = {}
2✔
46
      holdings.each do |holding|
2✔
47
        @holdings[holding.id] = holding.to_s
2✔
48
      end
49
    end
50
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