Module: Openphar::PublisherRegistry

Defined in:
lib/openphar/publisher_registry.rb

Overview

Single source of truth for "which publishers are registered."

Static frozen hash — adding a publisher means one edit here AND a new publisher module file. Specs verify the two stay in sync.

Constant Summary collapse

KNOWN_PUBLISHERS =
{
  "ChP" => {
    code: "ChP",
    label: "Chinese Pharmacopoeia",
    module_name: "Openphar::Models::Chp",
    editions: %w[ChP-2025 ChP-2020].freeze,
    homepage: "https://2025.chp.org.cn".freeze,
  }.freeze,
  "JP" => {
    code: "JP",
    label: "Japanese Pharmacopoeia",
    module_name: "Openphar::Models::JP",
    editions: %w[JP18].freeze,
    homepage: "https://www.mhlw.go.jp/topics/bukyoku/iyaku/yakkyoku/".freeze,
  }.freeze,
  "PhInt" => {
    code: "PhInt",
    label: "International Pharmacopoeia (WHO)",
    module_name: "Openphar::Models::PhInt",
    editions: %w[PhInt-13].freeze,
    homepage: "https://www.who.int/teams/health-product-and-policy-standards/inn-and-pharmacopoeia".freeze,
  }.freeze,
  "AHP" => {
    code: "AHP",
    label: "American Herbal Pharmacopoeia",
    module_name: "Openphar::Models::AHP",
    editions: [].freeze,
    homepage: "https://www.herbal-ahp.org/".freeze,
  }.freeze,
  "API" => {
    code: "API",
    label: "Ayurvedic Pharmacopoeia of India",
    module_name: "Openphar::Models::API",
    editions: [].freeze,
    homepage: "https://main.ayush.gov.in/".freeze,
  }.freeze,
  "HKCMMS" => {
    code: "HKCMMS",
    label: "Hong Kong Chinese Materia Medica Standards",
    module_name: "Openphar::Models::HKCMMS",
    editions: [].freeze,
    homepage: "https://www.cmchk.org.hk/".freeze,
  }.freeze,
  "THP" => {
    code: "THP",
    label: "Thai Herbal Pharmacopoeia",
    module_name: "Openphar::Models::THP",
    editions: [].freeze,
    homepage: "http://www.fda.moph.go.th/".freeze,
  }.freeze,
}.freeze

Class Method Summary collapse

Class Method Details

.[](code) ⇒ Object



67
68
69
# File 'lib/openphar/publisher_registry.rb', line 67

def [](code)
  KNOWN_PUBLISHERS[code.to_s]
end

.allObject



63
64
65
# File 'lib/openphar/publisher_registry.rb', line 63

def all
  KNOWN_PUBLISHERS
end

.codesObject



75
76
77
# File 'lib/openphar/publisher_registry.rb', line 75

def codes
  KNOWN_PUBLISHERS.keys.sort
end

.module_for(code) ⇒ Object



79
80
81
82
83
84
# File 'lib/openphar/publisher_registry.rb', line 79

def module_for(code)
  entry = self[code]
  return nil unless entry

  entry[:module_name].safe_constantize
end

.registered?(code) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/openphar/publisher_registry.rb', line 71

def registered?(code)
  KNOWN_PUBLISHERS.key?(code.to_s)
end