Module: Pubid::Bsi

Defined in:
lib/pubid/bsi.rb,
lib/pubid/bsi/model.rb,
lib/pubid/bsi/parser.rb,
lib/pubid/bsi/builder.rb,
lib/pubid/bsi/renderer.rb,
lib/pubid/bsi/identifier.rb,
lib/pubid/bsi/urn_parser.rb,
lib/pubid/bsi/identifiers.rb,
lib/pubid/bsi/urn_generator.rb,
lib/pubid/bsi/components/code.rb,
lib/pubid/bsi/components/date.rb,
lib/pubid/bsi/components/type.rb,
lib/pubid/bsi/identifiers/set.rb,
lib/pubid/bsi/identifiers/disc.rb,
lib/pubid/bsi/identifiers/flex.rb,
lib/pubid/bsi/identifiers/index.rb,
lib/pubid/bsi/single_identifier.rb,
lib/pubid/bsi/identifiers/method.rb,
lib/pubid/bsi/identifiers/section.rb,
lib/pubid/bsi/components/publisher.rb,
lib/pubid/bsi/identifiers/handbook.rb,
lib/pubid/bsi/identifiers/amendment.rb,
lib/pubid/bsi/identifiers/corrigendum.rb,
lib/pubid/bsi/identifiers/test_method.rb,
lib/pubid/bsi/identifiers/draft_document.rb,
lib/pubid/bsi/identifiers/national_annex.rb,
lib/pubid/bsi/identifiers/practice_guide.rb,
lib/pubid/bsi/identifiers/electronic_book.rb,
lib/pubid/bsi/identifiers/british_standard.rb,
lib/pubid/bsi/identifiers/addendum_document.rb,
lib/pubid/bsi/identifiers/expert_commentary.rb,
lib/pubid/bsi/identifiers/aerospace_standard.rb,
lib/pubid/bsi/identifiers/bundled_identifier.rb,
lib/pubid/bsi/identifiers/committee_document.rb,
lib/pubid/bsi/identifiers/published_document.rb,
lib/pubid/bsi/identifiers/supplement_document.rb,
lib/pubid/bsi/identifiers/supplementary_index.rb,
lib/pubid/bsi/identifiers/standalone_amendment.rb,
lib/pubid/bsi/identifiers/adopted_european_norm.rb,
lib/pubid/bsi/identifiers/detailed_specification.rb,
lib/pubid/bsi/identifiers/explanatory_supplement.rb,
lib/pubid/bsi/identifiers/consolidated_identifier.rb,
lib/pubid/bsi/identifiers/technical_specification.rb,
lib/pubid/bsi/identifiers/value_added_publication.rb,
lib/pubid/bsi/identifiers/british_industrial_practice.rb,
lib/pubid/bsi/identifiers/adopted_international_standard.rb,
lib/pubid/bsi/identifiers/publicly_available_specification.rb

Defined Under Namespace

Modules: Components, Identifier, Identifiers Classes: Builder, Collection, ExpertCommentary, NationalAnnex, Parser, Renderer, SingleIdentifier, Supplement, UrnGenerator, UrnParser

Constant Summary collapse

TYPED_STAGES_REGISTRY =

TYPED_STAGES_REGISTRY for native BSI types. Used by Pubid::Bsi.locate_stage to map abbreviations (e.g. “BS”, “PD”, “Handbook”) to typed stages.

[
  # British Standard (BS)
  Pubid::Components::TypedStage.new(
    code: :pubbs,
    stage_code: :published,
    type_code: :bs,
    abbr: ["BS"],
    name: "British Standard",
    harmonized_stages: %w[60.00 60.60],
  ),
  Pubid::Components::TypedStage.new(
    code: :drbs,
    stage_code: :draft,
    type_code: :bs,
    abbr: ["Draft BS", "DBS"],
    name: "Draft British Standard",
    harmonized_stages: %w[30.00 30.20 30.60 40.00 40.20 40.60],
  ),

  # Published Document (PD)
  Pubid::Components::TypedStage.new(
    code: :pubpd,
    stage_code: :published,
    type_code: :pd,
    abbr: ["PD"],
    name: "Published Document",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Publicly Available Specification (PAS)
  Pubid::Components::TypedStage.new(
    code: :pubpas,
    stage_code: :published,
    type_code: :pas,
    abbr: ["PAS"],
    name: "Publicly Available Specification",
    harmonized_stages: %w[60.00 60.60],
  ),

  # National Annex (NA)
  Pubid::Components::TypedStage.new(
    code: :pubna,
    stage_code: :published,
    type_code: :na,
    abbr: ["NA"],
    name: "National Annex",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Draft Document (DD)
  Pubid::Components::TypedStage.new(
    code: :pubdd,
    stage_code: :published,
    type_code: :dd,
    abbr: ["DD"],
    name: "Draft Document",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Flex Document
  Pubid::Components::TypedStage.new(
    code: :pubflex,
    stage_code: :published,
    type_code: :flex,
    abbr: ["Flex", "BSI Flex"],
    name: "BSI Flex",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Handbook
  Pubid::Components::TypedStage.new(
    code: :pubhandbook,
    stage_code: :published,
    type_code: :handbook,
    abbr: ["Handbook", "HB"],
    name: "BSI Handbook",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Practice Guide (PP)
  Pubid::Components::TypedStage.new(
    code: :pubpp,
    stage_code: :published,
    type_code: :pp,
    abbr: ["PP"],
    name: "Published Practice",
    harmonized_stages: %w[60.00 60.60],
  ),

  # British Industrial Practice (BIP)
  Pubid::Components::TypedStage.new(
    code: :pubbip,
    stage_code: :published,
    type_code: :bip,
    abbr: ["BIP"],
    name: "British Industrial Practice",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Aerospace/Specialized British Standard (with letter prefix)
  Pubid::Components::TypedStage.new(
    code: :pubaerospace,
    stage_code: :published,
    type_code: :aerospace,
    abbr: ["BS A", "BS AU", "BS C", "BS M", "BS S", "BS L", "BS TA",
           "BS MA", "BS PL", "BS QC", "BS G", "BS HC", "BS F", "BS X", "BS B"],
    name: "Aerospace/Specialized British Standard",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Index
  Pubid::Components::TypedStage.new(
    code: :pubindex,
    stage_code: :published,
    type_code: :index,
    abbr: ["Index"],
    name: "BSI Index",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Method
  Pubid::Components::TypedStage.new(
    code: :pubmethod,
    stage_code: :published,
    type_code: :method,
    abbr: ["Method", "Methods"],
    name: "BSI Method",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Section
  Pubid::Components::TypedStage.new(
    code: :pubsection,
    stage_code: :published,
    type_code: :section,
    abbr: ["Section"],
    name: "BSI Section",
    harmonized_stages: %w[60.00 60.60],
  ),

  # DISC (Delivering Information Solutions to Customers)
  Pubid::Components::TypedStage.new(
    code: :pubdisc,
    stage_code: :published,
    type_code: :disc,
    abbr: ["DISC"],
    name: "DISC",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Detailed Specification (with N or C notation)
  Pubid::Components::TypedStage.new(
    code: :pubdetailed_spec,
    stage_code: :published,
    type_code: :detailed_specification,
    abbr: ["DETAILED SPEC"],
    name: "Detailed Specification",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Standalone Amendment
  Pubid::Components::TypedStage.new(
    code: :standalone_amendment,
    stage_code: :published,
    type_code: :amendment,
    abbr: ["AMD"],
    name: "Amendment",
    harmonized_stages: %w[60.00 60.60],
  ),

  # Technical Specification
  Pubid::Components::TypedStage.new(
    code: :pubts,
    stage_code: :published,
    type_code: :ts,
    abbr: ["TS"],
    name: "Technical Specification",
    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:



226
227
228
# File 'lib/pubid/bsi.rb', line 226

def self.all_typed_stages
  @all_typed_stages ||= TYPED_STAGES_REGISTRY
end

.identifier_typesArray<Class>

Auto-discover all identifier types from the Identifiers namespace. Includes classes with explicit type declarations (Hash or nil).

Returns:

  • (Array<Class>)

    identifier classes (Pubid::Identifier subclasses)



216
217
218
219
220
221
222
# File 'lib/pubid/bsi.rb', line 216

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 < Pubid::Identifier }
    .select { |c| c.singleton_methods(false).include?(:type) }
    .reject { |c| c.name&.split("::")&.last == "Base" }
end

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

Lookup: abbreviation -> typed stage

Parameters:

  • abbr (String, Symbol)

    the abbreviation to find

Returns:



240
241
242
243
# File 'lib/pubid/bsi.rb', line 240

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



233
234
235
# File 'lib/pubid/bsi.rb', line 233

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

.parse(string) ⇒ Object



205
206
207
# File 'lib/pubid/bsi.rb', line 205

def self.parse(string)
  Identifier.parse(string)
end

.transform(data) ⇒ Object



209
210
211
# File 'lib/pubid/bsi.rb', line 209

def self.transform(data)
  Builder.build(data)
end