Class: IsoDoc::BIPM::Metadata

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

Constant Summary collapse

SI_ASPECT =
%w(A_e_deltanu A_e cd_Kcd_h_deltanu cd_Kcd full K_k_deltanu
K_k kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA
s_deltanu).freeze

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, locale, labels) ⇒ Metadata

Returns a new instance of Metadata.



14
15
16
17
18
19
20
21
22
23
# File 'lib/isodoc/bipm/metadata.rb', line 14

def initialize(lang, script, locale, labels)
  super
  here = File.join(File.dirname(__FILE__), "html", "si-aspect")
  si_paths = []
  SI_ASPECT.each do |s|
    si_paths << File.expand_path(File.join(here, "#{s}.png"))
  end
  set(:si_aspect_index, SI_ASPECT)
  set(:si_aspect_paths, si_paths)
end

Instance Method Details

#author(xml, _out) ⇒ Object



77
78
79
80
# File 'lib/isodoc/bipm/metadata.rb', line 77

def author(xml, _out)
  super
  authorizer(xml)
end

#authorizer(xml) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/isodoc/bipm/metadata.rb', line 82

def authorizer(xml)
  ret = xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = " \
                     "'authorizer']/organization"))
    .each_with_object([]) do |org, m|
    m << extract_variant(org.at(ns("./name")))
  end
  ret.empty? or set(:authorizer, ret)
end

#bibdate(isoxml, _out) ⇒ Object



71
72
73
74
75
# File 'lib/isodoc/bipm/metadata.rb', line 71

def bibdate(isoxml, _out)
  pubdate = isoxml
    .at(ns("//bibdata/date[not(@format)][@type = 'published']"))
  pubdate and set(:pubdate_monthyear, monthyr(pubdate.text))
end

#configurationObject



6
7
8
# File 'lib/isodoc/bipm/metadata.rb', line 6

def configuration
  Metanorma::BIPM.configuration
end

#docid(isoxml, _out) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/isodoc/bipm/metadata.rb', line 49

def docid(isoxml, _out)
  super
  docid_part(isoxml, %w(Appendix Annexe), "appendix", :appendixid)
  docid_part(isoxml, %w(Annex Appendice), "annexid", :annexid)
  docid_part(isoxml, %w(Part Partie), "part", :partid)
  set(:org_abbrev,
      isoxml.at(ns("//bibdata/ext/editorialgroup/committee"\
                   "[@acronym = 'JCGM']")) ? "JCGM" : "BIPM")
end

#docid_part(isoxml, labels, elem, key) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/isodoc/bipm/metadata.rb', line 59

def docid_part(isoxml, labels, elem, key)
  @lang == "fr" and labels.reverse!
  label1, label2 = labels
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/#{elem}"))
  dn and set(key, @i18n.l10n("#{label1} #{dn.text}"))
  dn and set("#{key}_alt".to_sym, @i18n.l10n("#{label2} #{dn.text}"))
end

#extract_person_names_affiliations(authors) ⇒ Object



67
68
69
# File 'lib/isodoc/bipm/metadata.rb', line 67

def extract_person_names_affiliations(authors)
  extract_person_affiliations(authors)
end

#status_print(status) ⇒ Object



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

def status_print(status)
  status == "procès-verbal" and return "Procès-Verbal"
  status == "cipm-mra" and return "CIPM-MRA"
  status.split(/[- ]/).map.with_index do |s, i|
    %w(en de).include?(s) && i.positive? ? s : s.capitalize
  end.join(" ")
end

#title(isoxml, _out) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/isodoc/bipm/metadata.rb', line 31

def title(isoxml, _out)
  lang1, lang2 = @lang == "fr" ? %w(fr en) : %w(en fr)
  set(:doctitle, title1(isoxml, "main", lang1))
  set(:docsubtitle, title1(isoxml, "main", lang2))
  %w(appendix annex part subtitle provenance).each do |e|
    set("#{e}title".to_sym, title1(isoxml, e, lang1))
    set("#{e}subtitle".to_sym, title1(isoxml, e, lang2))
  end
end

#title1(xml, type, lang) ⇒ Object



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

def title1(xml, type, lang)
  xml.at(ns("//bibdata/title[@type='title-#{type}']" \
    "[@language='#{lang}']"))
    &.children&.to_xml || ""
end