Module: Pubid::Nist

Defined in:
lib/pubid/nist.rb,
lib/pubid/nist/caster.rb,
lib/pubid/nist/parser.rb,
lib/pubid/nist/router.rb,
lib/pubid/nist/series.rb,
lib/pubid/nist/builder.rb,
lib/pubid/nist/renderer.rb,
lib/pubid/nist/series/ir.rb,
lib/pubid/nist/components.rb,
lib/pubid/nist/identifier.rb,
lib/pubid/nist/urn_parser.rb,
lib/pubid/nist/identifiers.rb,
lib/pubid/nist/series/base.rb,
lib/pubid/nist/series/crpl.rb,
lib/pubid/nist/series/fips.rb,
lib/pubid/nist/series/mono.rb,
lib/pubid/nist/preprocessor.rb,
lib/pubid/nist/configuration.rb,
lib/pubid/nist/series/ncstar.rb,
lib/pubid/nist/urn_generator.rb,
lib/pubid/nist/components/code.rb,
lib/pubid/nist/components/part.rb,
lib/pubid/nist/components/stage.rb,
lib/pubid/nist/identifiers/base.rb,
lib/pubid/nist/components/update.rb,
lib/pubid/nist/components/volume.rb,
lib/pubid/nist/identifiers/nsrds.rb,
lib/pubid/nist/identifiers/owmwp.rb,
lib/pubid/nist/components/edition.rb,
lib/pubid/nist/components/version.rb,
lib/pubid/nist/identifiers/ncstar.rb,
lib/pubid/nist/identifiers/report.rb,
lib/pubid/nist/identifiers/circular.rb,
lib/pubid/nist/identifiers/handbook.rb,
lib/pubid/nist/components/supplement.rb,
lib/pubid/nist/identifiers/monograph.rb,
lib/pubid/nist/supplement_identifier.rb,
lib/pubid/nist/components/translation.rb,
lib/pubid/nist/components/issue_number.rb,
lib/pubid/nist/identifiers/crpl_report.rb,
lib/pubid/nist/parser_output_normalizer.rb,
lib/pubid/nist/series/letter_preserving.rb,
lib/pubid/nist/identifiers/dated_document.rb,
lib/pubid/nist/identifiers/technical_note.rb,
lib/pubid/nist/circular_supplement_builder.rb,
lib/pubid/nist/identifiers/internal_report.rb,
lib/pubid/nist/identifiers/letter_circular.rb,
lib/pubid/nist/identifiers/circular_supplement.rb,
lib/pubid/nist/identifiers/commercial_standard.rb,
lib/pubid/nist/identifiers/special_publication.rb,
lib/pubid/nist/identifiers/grant_contractor_report.rb,
lib/pubid/nist/identifiers/miscellaneous_publication.rb,
lib/pubid/nist/identifiers/commercial_standards_monthly.rb,
lib/pubid/nist/identifiers/commercial_standard_emergency.rb,
lib/pubid/nist/identifiers/federal_information_processing_standards.rb

Defined Under Namespace

Modules: Components, Identifier, Identifiers, Series Classes: Builder, Caster, CircularSupplementBuilder, Configuration, ConfigurationError, Parser, ParserOutputNormalizer, Preprocessor, Renderer, Router, SupplementIdentifier, UrnGenerator, UrnParser

Constant Summary collapse

IDENTIFIER_TYPES =

Explicit registry of NIST identifier classes.

NIST identifier classes use ‘typed_stages` (not the `self.type` Hash pattern used by CEN/JCGM/ANSI), so they cannot be auto-discovered. Identifiers::Base is the fallback for unmapped series (e.g. AMS, VTS) and must be excluded from typed-stage aggregation.

[
  Identifiers::SpecialPublication,
  Identifiers::FederalInformationProcessingStandards,
  Identifiers::InteragencyReport,
  Identifiers::Handbook,
  Identifiers::TechnicalNote,
  Identifiers::Circular,
  Identifiers::CircularSupplement,
  Identifiers::CrplReport,
  Identifiers::Report,
  Identifiers::Monograph,
  Identifiers::MiscellaneousPublication,
  Identifiers::GrantContractorReport,
  Identifiers::Ncstar,
  Identifiers::Owmwp,
  Identifiers::Nsrds,
  Identifiers::LetterCircular,
  Identifiers::CommercialStandard,
  Identifiers::CommercialStandardEmergency,
  Identifiers::CommercialStandardsMonthly,
  Identifiers::DatedDocument,
  Identifiers::Base, # Fallback for unmapped series
].freeze

Class Method Summary collapse

Class Method Details

.all_typed_stagesArray<Pubid::Components::TypedStage>

Aggregate TYPED_STAGES from all identifier classes. Identifiers::Base is excluded because it has no typed stages and acts as the fallback for unmapped series.

Returns:



87
88
89
90
91
92
# File 'lib/pubid/nist.rb', line 87

def self.all_typed_stages
  @all_typed_stages ||= identifier_types
    .reject { |klass| klass == Identifiers::Base }
    .flat_map(&:typed_stages)
    .freeze
end

.configurationConfiguration

Get the configuration instance

Returns:



67
68
69
# File 'lib/pubid/nist.rb', line 67

def self.configuration
  @configuration ||= Configuration.new
end

.identifier_typesArray<Class>

All identifier classes for external consumption (export, website). Identifiers::Base is the fallback for unmapped series and is excluded from external type listings.

Returns:

  • (Array<Class>)

    identifier classes



79
80
81
# File 'lib/pubid/nist.rb', line 79

def self.identifier_types
  IDENTIFIER_TYPES.reject { |klass| klass == Identifiers::Base }
end

.locate_stage(abbr) ⇒ Pubid::Components::TypedStage?

Lookup: abbreviation -> typed stage

Parameters:

  • abbr (String, Symbol)

    the abbreviation to find

Returns:



108
109
110
111
# File 'lib/pubid/nist.rb', line 108

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. Identifiers::Base is excluded so it never gets selected by type code.

Parameters:

  • code (String, Symbol)

    the type code to find

Returns:

  • (Class, nil)

    the matching identifier class, or nil



98
99
100
101
102
103
# File 'lib/pubid/nist.rb', line 98

def self.locate_type(code)
  type_str = code.to_s
  identifier_types
    .reject { |klass| klass == Identifiers::Base }
    .find { |klass| klass.typed_stages.any? { |ts| ts.type_code.to_s == type_str } }
end

.parse(identifier) ⇒ Identifiers::Base

Parse a NIST identifier string

Parameters:

  • identifier (String)

    the identifier string to parse

Returns:



55
56
57
58
59
60
61
62
63
# File 'lib/pubid/nist.rb', line 55

def self.parse(identifier)
  # Use the Parser class's preprocessing method
  # Note: We call the class method directly to ensure preprocessing is applied
  parsed = Parser.class_parse_with_preprocessing(identifier)

  # Builder is stateless — lookups go through this module (Pubid::Nist)
  builder = Builder.new
  builder.build(parsed)
end