Module: Pubid::Xsf
- Extended by:
- PrefixesSupport
- Defined in:
- lib/pubid/xsf.rb,
lib/pubid/xsf/parser.rb,
lib/pubid/xsf/builder.rb,
lib/pubid/xsf/renderer.rb,
lib/pubid/xsf/identifier.rb,
lib/pubid/xsf/urn_parser.rb,
lib/pubid/xsf/identifiers.rb,
lib/pubid/xsf/urn_generator.rb,
lib/pubid/xsf/identifiers/xep.rb
Overview
XSF (XMPP Standards Foundation) flavor. Its documents are XEPs — XMPP Extension Protocols — printed as "XEP NNNN" with a 4-digit zero-padded number (e.g. "XEP 0001"). The simplest full flavor: a single identifier type, one string attribute.
Defined Under Namespace
Modules: Identifiers Classes: Builder, Identifier, Parser, Renderer, UrnGenerator, UrnParser
Constant Summary collapse
- PREFIXES =
Sole leading token an XSF identifier can start with (see the parser's
str("XEP")). "XSF" is the publisher name but never appears in a printed identifier, so it is not a prefix. ["XEP"].freeze
Class Method Summary collapse
-
.all_typed_stages ⇒ Array<Pubid::Components::TypedStage>
Build typed stage index from identifier types.
-
.identifier_types ⇒ Array<Class>
Auto-discover all identifier types from the Identifiers namespace.
-
.locate_stage(abbr) ⇒ Pubid::Components::TypedStage?
Lookup: abbreviation -> typed stage.
-
.locate_type(code) ⇒ Class?
Lookup: type code -> identifier class.
-
.parse(identifier) ⇒ Object
Parse an XSF identifier string.
Methods included from PrefixesSupport
Class Method Details
.all_typed_stages ⇒ Array<Pubid::Components::TypedStage>
Build typed stage index from identifier types
48 49 50 51 52 53 54 55 56 |
# File 'lib/pubid/xsf.rb', line 48 def self.all_typed_stages @all_typed_stages ||= identifier_types.flat_map do |klass| if klass.const_defined?(:TYPED_STAGES) klass.const_get(:TYPED_STAGES) else [] end end end |
.identifier_types ⇒ Array<Class>
Auto-discover all identifier types from the Identifiers namespace
39 40 41 42 43 44 |
# File 'lib/pubid/xsf.rb', line 39 def self.identifier_types @identifier_types ||= Identifiers.constants .filter_map { |c| begin; Identifiers.const_get(c); rescue NameError; nil; end } .select { |c| c.is_a?(Class) && c.singleton_methods(false).include?(:type) } .select { |c| c.type.is_a?(Hash) } end |
.locate_stage(abbr) ⇒ Pubid::Components::TypedStage?
Lookup: abbreviation -> typed stage
68 69 70 71 |
# File 'lib/pubid/xsf.rb', line 68 def self.locate_stage(abbr) abbr_str = abbr.to_s.upcase all_typed_stages.find { |s| s.abbr.any? { |a| a.to_s.upcase == abbr_str } } end |
.locate_type(code) ⇒ Class?
Lookup: type code -> identifier class
61 62 63 |
# File 'lib/pubid/xsf.rb', line 61 def self.locate_type(code) identifier_types.find { |t| t.type[:key].to_s == code.to_s } end |
.parse(identifier) ⇒ Object
Parse an XSF identifier string
25 26 27 28 29 30 31 |
# File 'lib/pubid/xsf.rb', line 25 def self.parse(identifier) if identifier.length > Pubid::MAX_INPUT_LENGTH raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE end Identifier.parse(identifier) end |