Class: Pubid::Oasis::UrnGenerator
- Inherits:
-
UrnGenerator::Base
- Object
- UrnGenerator::Base
- Pubid::Oasis::UrnGenerator
- Defined in:
- lib/pubid/oasis/urn_generator.rb
Overview
Emits urn:oasis:<slug>, echoing the verbatim original as a single URN
segment (OASIS slugs never contain ":"). The only characters that occur in
real records outside the URN-safe set are the space and a stray "]" (both
only in a handful of malformed records); these are percent-encoded so the
URN stays well-formed, and UrnParser reverses them exactly.
"OASIS amqp-core" -> "urn:oasis:amqp-core"
"OASIS OSLC-CM-v1.0-CS01" -> "urn:oasis:OSLC-CM-v1.0-CS01"
Constant Summary collapse
- ENCODE =
Character -> percent-encoding for the non-URN-safe characters that actually appear in OASIS slugs. Kept explicit (not a blanket URI escape) so clean slugs — dots, hyphens, mixed case — pass through unchanged.
{ " " => "%20", "]" => "%5D" }.freeze
Instance Attribute Summary
Attributes inherited from UrnGenerator::Base
Instance Method Summary collapse
Methods inherited from UrnGenerator::Base
#initialize, #maybe, #urn_edition, #urn_language, #urn_namespace, #urn_number, #urn_part, #urn_publisher, #urn_subpart, #urn_type, #urn_year
Constructor Details
This class inherits a constructor from Pubid::UrnGenerator::Base
Instance Method Details
#generate ⇒ Object
19 20 21 22 |
# File 'lib/pubid/oasis/urn_generator.rb', line 19 def generate slug = identifier.original.to_s.gsub(/[ \]]/) { |c| ENCODE[c] } "urn:oasis:#{slug}" end |