Module: Iev::FigureBuilder
- Defined in:
- lib/iev/figure_builder.rb
Overview
Hoists IEV figure references into dataset-shared Figure entities.
IEV source data carries figures as inline SIMG tags, which Utilities rewrites to AsciiDoc image macros (+image::/assets/images/parts/area/ FILE[Figure N - caption]+). This builder walks every concept’s localizations, finds those image macros, promotes each to a dataset-shared Glossarist::Figure entity, and rewrites the inline text to a V3 figure mention (+display}+).
The Figure entity is shared across concepts and languages — captions from different localizations merge into the same => text hash. The structural link from concept to figure is a FigureReference entry on ManagedConceptData#figures.
Extraction is destructive: it mutates DetailedDefinition#content and appends FigureReference entries. Returns the unique Figure entities so the exporter can persist them to figures/id.yaml.
Constant Summary collapse
- IMAGE_MACRO_REGEX =
Matches AsciiDoc image macros emitted by Utilities#process_simg_figures.
/ image::#{Regexp.escape(PATH_PREFIX)} \/(?<area>\d+)\/(?<file>[\w.-]+)\[(?<caption>[^\]]*)\] /x- CAPTION_REGEX =
Captures “Figure N” label and the trailing caption text.
/\A(?<label>Figure\s+\d+)\s*[–-]\s*(?<text>.+)\z/m
Class Method Summary collapse
-
.extract!(collection) ⇒ Array<Glossarist::Figure>
Unique figures, sorted by id.
Class Method Details
.extract!(collection) ⇒ Array<Glossarist::Figure>
Returns unique figures, sorted by id.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/iev/figure_builder.rb', line 40 def extract!(collection) figures_by_id = {} collection.each do |concept| concept.localizations.each do |l10n| process_localization(l10n, concept, figures_by_id) end end figures_by_id.values.sort_by(&:id) end |