Class: Pubid::Oasis::UrnParser

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

Overview

Parses OASIS URNs back into identifiers by reconstructing the printed form and delegating to the flavor's text parser.

UrnGenerator emits urn:oasis:<slug> (single segment) with the space and "]" characters percent-encoded; reverse exactly those two here.

urn:oasis:OSLC-CM-v1.0-CS01 -> OASIS OSLC-CM-v1.0-CS01
urn:oasis:amqp-core         -> OASIS amqp-core

Constant Summary collapse

DECODE =
{ "%20" => " ", "%5D" => "]" }.freeze

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#parse_urn(urn) ⇒ Object



16
17
18
19
# File 'lib/pubid/oasis/urn_parser.rb', line 16

def parse_urn(urn)
  slug = strip_namespace(urn).gsub(/%20|%5D/, DECODE)
  flavor_parse("OASIS #{slug}")
end