Class: IsoDoc::Generic::Metadata
- Inherits:
-
Metadata
- Object
- Metadata
- IsoDoc::Generic::Metadata
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
Class Attribute Details
._file ⇒ Object
Returns the value of attribute _file.
35
36
37
|
# File 'lib/isodoc/generic/metadata.rb', line 35
def _file
@_file
end
|
Class Method Details
.inherited(klass) ⇒ Object
rubocop:disable Lint/MissingSuper
38
39
40
|
# File 'lib/isodoc/generic/metadata.rb', line 38
def self.inherited(klass)
klass._file = caller_locations(1..1).first.absolute_path
end
|
Instance Method Details
#author(isoxml, _out) ⇒ Object
52
53
54
55
56
|
# File 'lib/isodoc/generic/metadata.rb', line 52
def author(isoxml, _out)
super
tc = isoxml.at(ns("//bibdata/contributor[role/description = 'committee']/organization/subdivision[@type = 'Committee']/name"))
set(:tc, tc.text) if tc
end
|
#doctype(isoxml, _out) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/isodoc/generic/metadata.rb', line 63
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) ⇒ Object
91
92
93
94
|
# File 'lib/isodoc/generic/metadata.rb', line 91
def ext(isoxml, _out)
b = isoxml&.at(ns("//bibdata/ext")) or return
set(:metadata_extensions, xmlhash2hash(b.to_hash)["ext"])
end
|
#images(isoxml, out) ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/isodoc/generic/metadata.rb', line 42
def images(isoxml, out)
default_logo_path =
File.expand_path(File.join(File.dirname(__FILE__), "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
|
#stage_abbr(status) ⇒ Object
58
59
60
61
|
# File 'lib/isodoc/generic/metadata.rb', line 58
def stage_abbr(status)
configuration.stage_abbreviations or return super
Hash(configuration.stage_abbreviations).dig(status)
end
|
#xmlhash2hash(hash) ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/isodoc/generic/metadata.rb', line 70
def xmlhash2hash(hash)
ret = {}
hash.nil? || hash[:kind] != "element" and return ret
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) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/isodoc/generic/metadata.rb', line 78
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
|