Module: Pubid::Calconnect
- Extended by:
- PrefixesSupport
- Defined in:
- lib/pubid/calconnect.rb,
lib/pubid/calconnect/parser.rb,
lib/pubid/calconnect/builder.rb,
lib/pubid/calconnect/renderer.rb,
lib/pubid/calconnect/identifier.rb,
lib/pubid/calconnect/urn_parser.rb,
lib/pubid/calconnect/identifiers.rb,
lib/pubid/calconnect/urn_generator.rb,
lib/pubid/calconnect/identifiers/standard.rb
Overview
CalConnect (The Calendaring and Scheduling Consortium) flavor.
Parses/renders the "CC …" numbering, e.g. "CC 18011:2018", "CC/DIR 10006:2019", "CC/Adv 0707.1:2007". Modeled on Pubid::Jis: a single flat identifier type (Identifiers::Standard) with no supplement layer.
Defined Under Namespace
Modules: Identifiers Classes: Builder, Identifier, Parser, Renderer, UrnGenerator, UrnParser
Constant Summary collapse
- PREFIXES =
Sole CalConnect publisher/leading token. Series letters (A, WD, R, S, CD, DIR, Adv, FDS) follow "CC/" and never lead a reference, so they are excluded per the PrefixesSupport inclusion policy.
["CC"].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 a CalConnect identifier string.
Methods included from PrefixesSupport
Class Method Details
.all_typed_stages ⇒ Array<Pubid::Components::TypedStage>
Build typed stage index from identifier types
49 50 51 52 53 54 55 56 57 |
# File 'lib/pubid/calconnect.rb', line 49 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
40 41 42 43 44 45 |
# File 'lib/pubid/calconnect.rb', line 40 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
69 70 71 72 |
# File 'lib/pubid/calconnect.rb', line 69 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
62 63 64 |
# File 'lib/pubid/calconnect.rb', line 62 def self.locate_type(code) identifier_types.find { |t| t.type[:key].to_s == code.to_s } end |
.parse(identifier) ⇒ Object
Parse a CalConnect identifier string
26 27 28 29 30 31 32 |
# File 'lib/pubid/calconnect.rb', line 26 def self.parse(identifier) if identifier.length > Pubid::MAX_INPUT_LENGTH raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE end Identifier.parse(identifier) end |