Class: Pubid::Export::ItuExporter

Inherits:
FlavorExporter show all
Defined in:
lib/pubid/export/itu_exporter.rb

Overview

Strategy for ITU, which uses a transform/model pattern without traditional identifier classes or TYPED_STAGES.

Constant Summary collapse

WEBSITE_KEY_OVERRIDES =
{
  "special_publication" => "special_publication",
}.freeze

Constants inherited from FlavorExporter

FlavorExporter::WRAPPER_CLASSES

Instance Attribute Summary

Attributes inherited from FlavorExporter

#flavor

Instance Method Summary collapse

Methods inherited from FlavorExporter

#initialize

Constructor Details

This class inherits a constructor from Pubid::Export::FlavorExporter

Instance Method Details

#exportObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pubid/export/itu_exporter.rb', line 12

def export
  klasses = resolve_itu_identifiers
  return nil if klasses.empty?

  fixture_data = fixture_examples

  identifier_types = klasses.map do |klass|
    info = extract_type_info(klass)
    type_key = info[:key]
    examples = fixture_data[type_key] || fixture_data[type_key.to_s] || []

    IdentifierTypeResult.new(
      key: info[:key],
      title: info[:title],
      short: info[:short],
      abbr: info[:abbr],
      typed_stages: [],
      examples: examples,
    )
  end

  FlavorResult.new(
    flavor: flavor,
    identifier_types: identifier_types,
    attributes: extract_attribute_names,
  )
end