Class: IsoDoc::Generic::Metadata

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

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, labels) ⇒ Metadata

Returns a new instance of Metadata.



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

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.



18
19
20
# File 'lib/isodoc/generic/metadata.rb', line 18

def _file
  @_file
end

Class Method Details

.inherited(k) ⇒ Object



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

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

Instance Method Details

#author(isoxml, _out) ⇒ Object



35
36
37
38
39
# File 'lib/isodoc/generic/metadata.rb', line 35

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

#baselocation(loc) ⇒ Object



25
26
27
28
29
# File 'lib/isodoc/generic/metadata.rb', line 25

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

#configurationObject



31
32
33
# File 'lib/isodoc/generic/metadata.rb', line 31

def configuration
  Metanorma::Generic.configuration
end

#ext(isoxml, out) ⇒ Object



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

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



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

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

#unpublished(status) ⇒ Object



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

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