Class: Pubid::Bsi::Scheme

Inherits:
Scheme
  • Object
show all
Defined in:
lib/pubid/bsi/scheme.rb

Constant Summary collapse

TYPED_STAGES_REGISTRY =

TYPED_STAGES_REGISTRY for native BSI types

[
  # 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
IDENTIFIER_CLASS_MAP =

Map type codes to identifier classes

{
  bs: "Identifiers::BritishStandard",
  pd: "Identifiers::PublishedDocument",
  pas: "Identifiers::PubliclyAvailableSpecification",
  na: "Identifiers::NationalAnnex",
  dd: "Identifiers::DraftDocument",
  flex: "Identifiers::Flex",
  handbook: "Identifiers::Handbook",
  pp: "Identifiers::PracticeGuide",
  bip: "Identifiers::BritishIndustrialPractice",
  aerospace: "Identifiers::AerospaceStandard",
  index: "Identifiers::Index",
  method: "Identifiers::Method",
  section: "Identifiers::Section",
  disc: "Identifiers::Disc",
  bundled: "Identifiers::BundledIdentifier",
  detailed_specification: "Identifiers::DetailedSpecification",
  standalone_amendment: "Identifiers::StandaloneAmendment",
  ts: "Identifiers::TechnicalSpecification",
  committee_document: "Identifiers::CommitteeDocument",
  explanatory_supplement: "Identifiers::ExplanatorySupplement",
  supplementary_index: "Identifiers::SupplementaryIndex",
  test_method: "Identifiers::TestMethod",
  set: "Identifiers::Set",
}.freeze
DEFAULT_TYPED_STAGE =

Default typed stage for when no match is found

Pubid::Components::TypedStage.new(
  code: :pubbs,
  stage_code: :published,
  type_code: :bs,
  abbr: ["BS"],
  name: "British Standard",
  harmonized_stages: %w[60.00 60.60],
).freeze

Instance Attribute Summary

Attributes inherited from Scheme

#identifiers, #languages, #publishers, #stages, #supplement_identifiers, #types

Instance Method Summary collapse

Methods inherited from Scheme

#all_identifier_classes, #all_typed_stages, #configure, #identifier_class_index, #initialize, #locate_typed_stage_by_harmonized_code, #locate_typed_stage_by_stage_code, #supplement_typed_stages, #typed_stage_index, #typed_stages

Constructor Details

This class inherits a constructor from Pubid::Scheme

Instance Method Details

#locate_identifier_klass_by_type_code(type_code) ⇒ Object



232
233
234
235
236
237
238
239
240
# File 'lib/pubid/bsi/scheme.rb', line 232

def locate_identifier_klass_by_type_code(type_code)
  class_name = IDENTIFIER_CLASS_MAP[type_code.to_sym]
  return Identifiers::BritishStandard unless class_name

  # Convert string to actual class
  class_name.split("::").reduce(Pubid::Bsi) do |mod, name|
    mod.const_get(name)
  end
end

#locate_typed_stage_by_abbr(abbr) ⇒ Object



225
226
227
228
229
230
# File 'lib/pubid/bsi/scheme.rb', line 225

def locate_typed_stage_by_abbr(abbr)
  abbr_str = abbr.to_s.strip
  TYPED_STAGES_REGISTRY.find do |ts|
    ts.abbr.include?(abbr_str)
  end || DEFAULT_TYPED_STAGE
end