Module: Pubid::Cie
- Defined in:
- lib/pubid/cie.rb,
lib/pubid/cie/parser.rb,
lib/pubid/cie/builder.rb,
lib/pubid/cie/identifier.rb,
lib/pubid/cie/urn_parser.rb,
lib/pubid/cie/identifiers.rb,
lib/pubid/cie/urn_generator.rb,
lib/pubid/cie/components/code.rb,
lib/pubid/cie/single_identifier.rb,
lib/pubid/cie/identifiers/bundle.rb,
lib/pubid/cie/components/language.rb,
lib/pubid/cie/identifiers/standard.rb,
lib/pubid/cie/identifiers/identical.rb,
lib/pubid/cie/supplement_identifier.rb,
lib/pubid/cie/identifiers/conference.rb,
lib/pubid/cie/identifiers/supplement.rb,
lib/pubid/cie/identifiers/corrigendum.rb,
lib/pubid/cie/identifiers/dual_published.rb,
lib/pubid/cie/identifiers/joint_published.rb,
lib/pubid/cie/identifiers/tutorial_bundle.rb
Defined Under Namespace
Modules: Components, Identifiers Classes: Builder, Identifier, Parser, SingleIdentifier, SupplementIdentifier, UrnGenerator, UrnParser
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: class name -> identifier class Since CIE lacks self.type, locate by class name suffix.
-
.parse(input) ⇒ Object
Main entry point for CIE identifiers Delegates to Identifier.parse.
Class Method Details
.all_typed_stages ⇒ Array<Pubid::Components::TypedStage>
Build typed stage index from identifier types.
38 39 40 41 42 43 44 45 46 |
# File 'lib/pubid/cie.rb', line 38 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. CIE identifier classes extend Lutaml::Model::Serializable via SingleIdentifier / SupplementIdentifier, without a self.type Hash. We discover by checking for subclasses of those base types.
30 31 32 33 34 |
# File 'lib/pubid/cie.rb', line 30 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 < SingleIdentifier || c < SupplementIdentifier) } end |
.locate_stage(abbr) ⇒ Pubid::Components::TypedStage?
Lookup: abbreviation -> typed stage
62 63 64 65 |
# File 'lib/pubid/cie.rb', line 62 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: class name -> identifier class Since CIE lacks self.type, locate by class name suffix
52 53 54 55 56 57 |
# File 'lib/pubid/cie.rb', line 52 def self.locate_type(code) identifier_types.find do |t| t.name.split("::").last.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, "") == code.to_s.downcase || t.name.split("::").last.downcase == code.to_s.downcase end end |
.parse(input) ⇒ Object
Main entry point for CIE identifiers Delegates to Identifier.parse
21 22 23 |
# File 'lib/pubid/cie.rb', line 21 def self.parse(input) Identifier.parse(input) end |