Class: Pubid::Bsi::UrnParser

Inherits:
UrnParser::Base show all
Defined in:
lib/pubid/bsi/urn_parser.rb

Overview

Parses BSI URNs back into identifiers.

UrnGenerator emits:

urn:bsi:{publisher}:{number}:{year}[:{supp_type}:{supp_number}:{supp_year}]

publisher is the lowercase publisher (e.g., “bs”, “pd”). supplement triples (‘amd`/`cor`/`add`) follow the base identifier.

Examples:

  • urn:bsi:bs:9001:2015 → BS 9001:2015

  • urn:bsi:bs:9001:2015:amd:1:2020 → BS 9001:2015/A1:2020

Constant Summary collapse

SUPPLEMENT_ABBR =
{
  "amd" => "Amd",
  "cor" => "Cor",
  "add" => "Add",
}.freeze

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#parse_urn(urn) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pubid/bsi/urn_parser.rb', line 23

def parse_urn(urn)
  body = strip_namespace(urn)
  parts = split_parts(body)

  publisher_token, number, year, *supplement_parts = parts
  publisher = publisher_token.upcase
  text = "#{publisher} #{number}"
  text += ":#{year}" if year
  text += build_supplements(supplement_parts)
  flavor_parse(text)
end