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

pulibrary / bibdata / b3c4a532-5da0-46f8-9c20-20018605a028

21 Mar 2025 08:11PM UTC coverage: 42.257% (-49.9%) from 92.185%
b3c4a532-5da0-46f8-9c20-20018605a028

push

circleci

sandbergja
Move various gems from the default Gemfile group to a more appropriate group

1599 of 3784 relevant lines covered (42.26%)

2.56 hits per line

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

40.91
/marc_to_solr/lib/uri_ark.rb
1
# Class modeling the ARK standard for URL's
2
# @see https://tools.ietf.org/html/draft-kunze-ark-18
3
class URI::ARK < URI::Generic
1✔
4
  attr_reader :nmah, :naan, :name
1✔
5

6
  ARK_REGEX = %r{://(.+)/ark:/(.+)/(.+)/?}
1✔
7
  PRINCETON_ARK_REGEX = %r{[/?]ark:/88435/(.+)/?}
1✔
8

9
  # Constructs an ARK from a URL
10
  # @param url [URI::Generic] the URL for the ARK resource
11
  # @return [URI::ARK] the ARK
12
  def self.parse(url:)
1✔
13
    url = URI.parse(url) unless url.is_a? URI::Generic
×
14
    build(
×
15
      scheme: url.scheme,
16
      userinfo: url.userinfo,
17
      host: url.host,
18
      port: url.port,
19
      registry: url.registry,
20
      path: url.path,
21
      opaque: url.opaque,
22
      query: url.query,
23
      fragment: url.fragment
24
    )
25
  end
26

27
  # Validates whether or not a URL is an ARK URL
28
  # @param uri [URI::Generic] a URL
29
  # @return [TrueClass, FalseClass]
30
  def self.princeton_ark?(url:)
1✔
31
    return false if url.to_s.start_with?('http:http:')
×
32
    return false unless PRINCETON_ARK_REGEX.match(url.to_s)
×
33
    return false unless ARK_REGEX.match(url.to_s)
×
34

35
    true
×
36
  end
37

38
  # Constructor
39
  def initialize(*arg)
1✔
40
    super(*arg)
×
41
    extract_components!
×
42
  end
43

44
  private
1✔
45

46
    # Extract the components from the ARK URL into member variables
47
    def extract_components!
1✔
48
      raise StandardError, "Invalid ARK URL using: #{self.to_s}" unless self.class.princeton_ark?(url: self)
×
49

50
      m = ARK_REGEX.match(self.to_s)
×
51

52
      @nmah = m[1]
×
53
      @naan = m[2]
×
54
      @name = m[3]
×
55
    end
56
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