class IsoDoc::Generic::Metadata

Attributes

_file[RW]

Public Class Methods

inherited(klass) click to toggle source
# File lib/isodoc/generic/metadata.rb, line 47
def self.inherited(klass) # rubocop:disable Lint/MissingSuper
  klass._file = caller_locations(1..1).first.absolute_path
end
new(lang, script, labels) click to toggle source
Calls superclass method
# File lib/isodoc/generic/metadata.rb, line 31
def initialize(lang, script, labels)
  super
  here = File.dirname(__FILE__)
  default_logo_path =
    File.expand_path(File.join(here, "html", "logo.jpg"))
  set(:logo, baselocation(configuration.logo_path) || default_logo_path)
  unless configuration.logo_paths.nil?
    set(:logo_paths,
        Array(configuration.logo_paths).map { |p| baselocation(p) })
  end
end

Public Instance Methods

author(isoxml, _out) click to toggle source
Calls superclass method
# File lib/isodoc/generic/metadata.rb, line 51
def author(isoxml, _out)
  super
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
  set(:tc, tc.text) if tc
end
doctype(isoxml, _out) click to toggle source
Calls superclass method
# File lib/isodoc/generic/metadata.rb, line 68
def doctype(isoxml, _out)
  super
  b = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}")) ||
    isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
  a = b["abbreviation"] and set(:doctype_abbr, a)
end
ext(isoxml, _out) click to toggle source
# File lib/isodoc/generic/metadata.rb, line 98
def ext(isoxml, _out)
  b = isoxml&.at(ns("//bibdata/ext")) or return
  set(:metadata_extensions, xmlhash2hash(b.to_hash)["ext"])
end
stage_abbr(status) click to toggle source
Calls superclass method
# File lib/isodoc/generic/metadata.rb, line 57
def stage_abbr(status)
  return super unless configuration.stage_abbreviations

  Hash(configuration.stage_abbreviations).dig(status)
end
unpublished(status) click to toggle source
# File lib/isodoc/generic/metadata.rb, line 63
def unpublished(status)
  stages = configuration&.published_stages || ["published"]
  !(Array(stages).map { |m| m.downcase }.include? status.downcase)
end
xmlhash2hash(hash) click to toggle source
# File lib/isodoc/generic/metadata.rb, line 75
def xmlhash2hash(hash)
  ret = {}
  return ret if hash.nil? || hash[:kind] != "element"

  hash[:attr].nil? or
    hash[:attr].each { |k, v| ret["#{hash[:name]}_#{k}"] = v }
  ret[hash[:name]] = hash[:kids] ? xmlhash2hash_kids(hash) : hash[:text]
  ret
end
xmlhash2hash_kids(hash) click to toggle source
# File lib/isodoc/generic/metadata.rb, line 85
def xmlhash2hash_kids(hash)
  c = {}
  hash[:kids].each do |n|
    xmlhash2hash(n).each do |k1, v1|
      c[k1] = if c[k1].nil? then v1
              elsif c[k1].is_a?(Array) then c[k1] << v1
              else [c[k1], v1]
              end
    end
  end
  c
end