Module: Pubid::CenCenelec

Defined in:
lib/pubid/cen_cenelec.rb,
lib/pubid/cen_cenelec/parser.rb,
lib/pubid/cen_cenelec/builder.rb,
lib/pubid/cen_cenelec/renderer.rb,
lib/pubid/cen_cenelec/identifier.rb,
lib/pubid/cen_cenelec/urn_parser.rb,
lib/pubid/cen_cenelec/identifiers.rb,
lib/pubid/cen_cenelec/urn_generator.rb,
lib/pubid/cen_cenelec/identifiers/base.rb,
lib/pubid/cen_cenelec/identifiers/guide.rb,
lib/pubid/cen_cenelec/single_identifier.rb,
lib/pubid/cen_cenelec/identifiers/fragment.rb,
lib/pubid/cen_cenelec/identifiers/amendment.rb,
lib/pubid/cen_cenelec/supplement_identifier.rb,
lib/pubid/cen_cenelec/identifiers/cen_report.rb,
lib/pubid/cen_cenelec/identifiers/corrigendum.rb,
lib/pubid/cen_cenelec/identifiers/european_norm.rb,
lib/pubid/cen_cenelec/identifiers/technical_report.rb,
lib/pubid/cen_cenelec/identifiers/european_prestandard.rb,
lib/pubid/cen_cenelec/identifiers/adopted_european_norm.rb,
lib/pubid/cen_cenelec/identifiers/cen_workshop_agreement.rb,
lib/pubid/cen_cenelec/identifiers/european_specification.rb,
lib/pubid/cen_cenelec/identifiers/harmonization_document.rb,
lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb,
lib/pubid/cen_cenelec/identifiers/technical_specification.rb,
lib/pubid/cen_cenelec/identifiers/cenelec_harmonization_document.rb

Defined Under Namespace

Modules: Identifier, Identifiers Classes: Builder, Parser, Renderer, SingleIdentifier, SupplementIdentifier, UrnGenerator, UrnParser

Constant Summary collapse

TYPED_STAGES_REGISTRY =

TYPED_STAGES_REGISTRY for native CEN types

[
  # European Norm (EN)
  Pubid::Components::TypedStage.new(
    code: :puben,
    stage_code: :published,
    type_code: :en,
    abbr: ["EN"],
    name: "European Norm",
    harmonized_stages: %w[60.00 60.60],
  ),
  Pubid::Components::TypedStage.new(
    code: :pren,
    stage_code: :proposal,
    type_code: :en,
    abbr: ["prEN"],
    name: "Proposal European Norm",
    harmonized_stages: %w[30.00 30.20 30.60 30.92 30.98 30.99],
  ),
  Pubid::Components::TypedStage.new(
    code: :fpren,
    stage_code: :final_proposal,
    type_code: :en,
    abbr: ["FprEN"],
    name: "Final Proposal European Norm",
    harmonized_stages: %w[40.00 40.20 40.60 40.92 40.98 40.99],
  ),

  # Technical Specification (TS)
  Pubid::Components::TypedStage.new(
    code: :pubts,
    stage_code: :published,
    type_code: :ts,
    abbr: ["TS"],
    name: "Technical Specification",
    harmonized_stages: %w[60.00 60.60],
  ),
  Pubid::Components::TypedStage.new(
    code: :prts,
    stage_code: :proposal,
    type_code: :ts,
    abbr: ["prTS"],
    name: "Proposal Technical Specification",
    harmonized_stages: %w[30.00 30.20 30.60 30.92 30.98 30.99],
  ),

  # Technical Report (TR)
  Pubid::Components::TypedStage.new(
    code: :pubtr,
    stage_code: :published,
    type_code: :tr,
    abbr: ["TR"],
    name: "Technical Report",
    harmonized_stages: %w[60.00 60.60],
  ),

  # CEN Workshop Agreement (CWA)
  Pubid::Components::TypedStage.new(
    code: :pubcwa,
    stage_code: :published,
    type_code: :cwa,
    abbr: ["CWA"],
    name: "CEN Workshop Agreement",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Guide
  Pubid::Components::TypedStage.new(
    code: :pubguide,
    stage_code: :published,
    type_code: :guide,
    abbr: ["Guide"],
    name: "Guide",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Harmonization Document (HD)
  Pubid::Components::TypedStage.new(
    code: :pubhd,
    stage_code: :published,
    type_code: :hd,
    abbr: ["HD"],
    name: "Harmonization Document",
    harmonized_stages: %w[60.00 60.60],
  ),

  # European Specification (ES)
  Pubid::Components::TypedStage.new(
    code: :pubes,
    stage_code: :published,
    type_code: :es,
    abbr: ["ES"],
    name: "European Specification",
    harmonized_stages: %w[60.00 60.60],
  ),

  # CEN Report (CR)
  Pubid::Components::TypedStage.new(
    code: :pubcr,
    stage_code: :published,
    type_code: :cr,
    abbr: ["CR"],
    name: "CEN Report",
    harmonized_stages: %w[60.00 60.60],
  ),

  # European Prestandard (ENV)
  Pubid::Components::TypedStage.new(
    code: :pubenv,
    stage_code: :published,
    type_code: :env,
    abbr: ["ENV"],
    name: "European Prestandard",
    harmonized_stages: %w[60.00 60.60],
  ),
].freeze
DEFAULT_TYPED_STAGE =

Default typed stage for when no match is found

Pubid::Components::TypedStage.new(
  code: :puben,
  stage_code: :published,
  type_code: :en,
  abbr: ["EN"],
  name: "European Norm",
  harmonized_stages: %w[60.00 60.60],
).freeze

Class Method Summary collapse

Class Method Details

.all_typed_stagesArray<Pubid::Components::TypedStage>

Build typed stage index from the module’s TYPED_STAGES_REGISTRY

Returns:



158
159
160
# File 'lib/pubid/cen_cenelec.rb', line 158

def self.all_typed_stages
  TYPED_STAGES_REGISTRY
end

.identifier_typesArray<Class>

Auto-discover all identifier types from the Identifiers namespace

Returns:

  • (Array<Class>)

    identifier classes that define a self.type Hash



149
150
151
152
153
154
# File 'lib/pubid/cen_cenelec.rb', line 149

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

Parameters:

  • abbr (String, Symbol)

    the abbreviation to find

Returns:



172
173
174
175
# File 'lib/pubid/cen_cenelec.rb', line 172

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

Parameters:

  • code (String, Symbol)

    the type key to find

Returns:

  • (Class, nil)

    the matching identifier class



165
166
167
# File 'lib/pubid/cen_cenelec.rb', line 165

def self.locate_type(code)
  identifier_types.find { |t| t.type[:key].to_s == code.to_s }
end

.parse(identifier) ⇒ Object



143
144
145
# File 'lib/pubid/cen_cenelec.rb', line 143

def self.parse(identifier)
  CenCenelec::Identifier.parse(identifier)
end