Class: IsoDoc::Generic::Metadata

Inherits:
Metadata
  • Object
show all
Includes:
Utils
Defined in:
lib/isodoc/generic/metadata.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#baselocation, #configuration, #fileloc

Constructor Details

#initialize(lang, script, labels) ⇒ Metadata

Returns a new instance of Metadata.



9
10
11
12
13
14
15
16
17
# File 'lib/isodoc/generic/metadata.rb', line 9

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

Class Attribute Details

._fileObject

Returns the value of attribute _file.



20
21
22
# File 'lib/isodoc/generic/metadata.rb', line 20

def _file
  @_file
end

Class Method Details

.inherited(k) ⇒ Object



23
24
25
# File 'lib/isodoc/generic/metadata.rb', line 23

def self.inherited( k )
  k._file = caller_locations.first.absolute_path
end

Instance Method Details

#author(isoxml, _out) ⇒ Object

def baselocation(loc)

  return nil if loc.nil?
  File.expand_path(File.join(File.dirname(
    self.class.respond_to?(:_file) ? (self.class::_file || __FILE__) :
    __FILE__),
  "..", "..", "..", loc))
end

def configuration
  Metanorma::Generic.configuration
end


41
42
43
44
45
# File 'lib/isodoc/generic/metadata.rb', line 41

def author(isoxml, _out)
  super
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
  set(:tc, tc.text) if tc
end

#ext(isoxml, out) ⇒ Object



57
58
59
60
61
62
# File 'lib/isodoc/generic/metadata.rb', line 57

def ext(isoxml, out)
  Array(configuration.).each do |e|
    b = isoxml&.at(ns("//bibdata/ext/#{e}"))&.text or next
    set(e.to_sym, b)
  end
end

#stage_abbr(status) ⇒ Object



47
48
49
50
# File 'lib/isodoc/generic/metadata.rb', line 47

def stage_abbr(status)
  return super unless configuration.stage_abbreviations
  Hash(configuration.stage_abbreviations).dig(status)
end

#unpublished(status) ⇒ Object



52
53
54
55
# File 'lib/isodoc/generic/metadata.rb', line 52

def unpublished(status)
  stages = configuration&.published_stages || ["published"]
  !(Array(stages).map { |m| m.downcase }.include? status.downcase)
end