Module: OpenASN::Parsers
- Defined in:
- lib/openasn/parsers.rb
Overview
Tier B body parsers, keyed by the parser ids in fetch-manifest.json.
Contract: parse(parser_id, body) -> Array of CIDR/IP string tokens (junk tokens are fine — CidrUtils drops them). UNKNOWN parser ids make #known? false and the executor SKIPS that source with a warning: that's the forward-compatibility deal that lets the data repo add sources without breaking old gems.
Parsers are deliberately tolerant of cosmetic drift (extra columns, comments, header rows) and deliberately strict about shape drift (a JSON schema change raises ParseError -> the executor keeps stale data and records the error, visible in OpenASN.dataset_info).
Defined Under Namespace
Classes: ParseError
Constant Summary collapse
- PARSERS =
{}
Class Method Summary collapse
Class Method Details
.known?(id) ⇒ Boolean
26 |
# File 'lib/openasn/parsers.rb', line 26 def self.known?(id) = PARSERS.key?(id) |
.parse(id, body) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/openasn/parsers.rb', line 28 def self.parse(id, body) handler = PARSERS[id] or raise ParseError, "unknown parser #{id}" handler.call(body) rescue ParseError raise rescue StandardError => e raise ParseError, "#{id}: #{e.class}: #{e.}" end |
.register(id, &block) ⇒ Object
25 |
# File 'lib/openasn/parsers.rb', line 25 def self.register(id, &block) = PARSERS[id] = block |