Module: Pubid::Bsi::Identifier

Defined in:
lib/pubid/bsi/identifier.rb

Class Method Summary collapse

Class Method Details

.parse(string) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pubid/bsi/identifier.rb', line 6

def self.parse(string)
  # Delegate to IEC for bare IEC identifiers
  # This handles IEC-specific features like VAP suffixes (CSV, RLV, etc.)
  # and consolidated supplements (+AMD1:2001)
  if string.match?(/\bIEC\b/) &&
      (string.match?(/\s+(CSV|CMV|RLV|SER|EXV|PAC|PRV)\b/) ||
       string.match?(/\+AMD\d+:/) ||
       string.match?(/\+COR\d+:/))
    return Pubid::Iec.parse(string)
  end

  parser = Parser.new
  scheme = Scheme.new

  parsed = parser.parse(string)
  Builder.build(parsed, scheme)
rescue Parslet::ParseFailed => e
  raise StandardError, "Failed to parse '#{string}': #{e.message}"
end