Module: Pubid::Nist

Extended by:
PrefixesSupport
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/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, Identifiers, Series Classes: Builder, Caster, CircularSupplementBuilder, Configuration, ConfigurationError, Identifier, Parser, ParserOutputNormalizer, Preprocessor, Renderer, Router, SupplementIdentifier, UrnGenerator, UrnParser

Constant Summary collapse

PREFIXES =

Publisher prefixes (NBS/NIST) plus the "simple series" tokens that can begin a printed reference on their own — mirrors the parser's publisher and simple_series rules (lib/pubid/nist/parser.rb). Compound series that only appear glued to a publisher (e.g. "NBS CRPL-F-A") are excluded because they never lead a routable reference by themselves.

%w[
  NIST NBS
  AMS VTS BSS BMS BH FIPS GCR HB MONO MP NCSTAR NSRDS IR SP TN CSWP
  AI CIRC CS CSM CRPL LCIRC OWMWP PC RPT SIBS TIBM TTB EAB JPCRD JRES
  CHIPS NWIRP RB
].freeze
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

Methods included from PrefixesSupport

prefix_flavor_key, prefixes

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:



105
106
107
108
109
110
# File 'lib/pubid/nist.rb', line 105

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:



85
86
87
# File 'lib/pubid/nist.rb', line 85

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



97
98
99
# File 'lib/pubid/nist.rb', line 97

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:



126
127
128
129
# File 'lib/pubid/nist.rb', line 126

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



116
117
118
119
120
121
# File 'lib/pubid/nist.rb', line 116

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:



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/pubid/nist.rb', line 69

def self.parse(identifier)
  if identifier.length > Pubid::MAX_INPUT_LENGTH
    raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
  end

  # 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