Class: Pubid::Iso::Normalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/pubid/iso/normalizer.rb

Overview

Applies pre-parse normalizations to ISO identifier strings, then dispatches to the parser/builder. Handles Cyrillic (Russian) translations, legacy update_codes regex rewrites, and the DAD/FDAM pattern that the PEG parser cannot recognize because it treats “/” as a copublisher separator.

Constant Summary collapse

DAD_PATTERN =
/^(.+?)\/(F?DAD)\s+(\d+)(?::(\d{4}))?$/.freeze

Class Method Summary collapse

Class Method Details

.apply(identifier) ⇒ Pubid::Iso::Identifier

Apply all normalizations to an identifier string and return the parsed identifier object.

Parameters:

  • identifier (String)

Returns:



17
18
19
20
21
22
23
24
25
# File 'lib/pubid/iso/normalizer.rb', line 17

def apply(identifier)
  if (match = identifier.match(DAD_PATTERN))
    parse_dad_pattern(match)
  else
    normalized = Core::UpdateCodes.apply(identifier, :iso)
    normalized = normalize_cyrillic(normalized)
    parse_with_builder(normalized)
  end
end