# Copyright (c) 2020 Jerome Arbez-Gindre # frozen_string_literal: true require('csv') require('defmastership/set_join_hack') module DefMastership # format lines per definition class CSVFormatterBody def initialize(doc, definition) @doc = doc @definition = definition end def fixed [@definition.type, @definition.reference, @definition.value, @definition.sha256_short] end def wrong_explicit_checksum wrong_explicit_checksum = @definition.wrong_explicit_checksum wrong_explicit_checksum ? [wrong_explicit_checksum] : [''] end def explicit_version explicit_version = @definition.explicit_version explicit_version ? [explicit_version] : [''] end def labels [@definition.labels.join("\n")] end def eref @doc.eref.map { |key,| @definition.eref.fetch(key, []).join("\n") } end def iref [@definition.iref.join("\n")] end def attributes @doc.attributes.map { |key,| @definition.attributes.fetch(key, '') } end end end