Class: Pubid::Iec::Parser
- Inherits:
-
Parslet::Parser
- Object
- Parslet::Parser
- Pubid::Iec::Parser
- Defined in:
- lib/pubid/iec/parser.rb
Constant Summary collapse
- DASH_CHARS =
["-", "‑", "‐"].freeze
- TYPED_STAGES =
We need to sort by length to match longest first because that’s how Parslet works
Pubid::Iec::Scheme.typed_stages .map(&:abbr).flatten.sort_by(&:length).reverse
- TYPED_STAGES_SUPPLEMENTS =
Pubid::Iec::Scheme.supplement_typed_stages .map(&:abbr).flatten.sort_by(&:length).reverse
- ORGANIZATIONS =
%w[ IEC ISO IEEE CIW SAE CIE ASME ASTM OECD HL7 CEI UNDP ].freeze
- EDITION_STRINGS =
%w[Edition Ed. ED Ed].freeze
- IEV_SHORTHAND =
/\AIEV(?=\z|[\s-])/
Instance Method Summary collapse
-
#parse(input) ⇒ Object
Preprocess input to normalize tab-separated editions and other formats.
Methods included from Parser::CommonParseMethods
Methods included from Parser::CommonParseRules
Instance Method Details
#parse(input) ⇒ Object
Preprocess input to normalize tab-separated editions and other formats
401 402 403 404 405 406 407 408 409 |
# File 'lib/pubid/iec/parser.rb', line 401 def parse(input) # Normalize tab-separated editions: "IECEE AD-001\tED1.6" -> "IECEE AD-001 ED1.6" normalized = input.gsub("\t", " ") # Normalize comma-separated editions: "IEC CAB-G01:2025-02, Ed. 2.1" -> "IEC CAB-G01:2025-02 Ed. 2.1" normalized = normalized.gsub(/,\s+Ed\./, " Ed.") # Expand IEV shorthand: "IEV" / "IEV-351" -> "IEC 60050" / "IEC 60050-351" normalized = normalized.sub(IEV_SHORTHAND, "IEC 60050") super(normalized) end |