Class: IsoDoc::Bipm::Metadata
- Inherits:
-
Generic::Metadata
- Object
- Generic::Metadata
- IsoDoc::Bipm::Metadata
- 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
- COMMITEE_XPATH =
<<~XPATH.freeze //bibdata/contributor[role/description = 'committee']/organization/subdivision[@type = 'Committee'] XPATH
Instance Method Summary collapse
- #author(xml, _out) ⇒ Object
- #bibdate(isoxml, _out) ⇒ Object
- #committee(xml) ⇒ Object
- #configuration ⇒ Object
- #docid(xml, _out) ⇒ Object
- #docid_part(isoxml, labels, elem, key) ⇒ Object
- #extract_person_names_affiliations(authors) ⇒ Object
- #images(xml, out) ⇒ Object
- #status_print(status) ⇒ Object
- #title(isoxml, _out) ⇒ Object
- #title1(xml, type, lang) ⇒ Object
Instance Method Details
#author(xml, _out) ⇒ Object
73 74 75 76 |
# File 'lib/isodoc/bipm/metadata.rb', line 73 def (xml, _out) super committee(xml) end |
#bibdate(isoxml, _out) ⇒ Object
67 68 69 70 71 |
# File 'lib/isodoc/bipm/metadata.rb', line 67 def bibdate(isoxml, _out) pubdate = isoxml .at(ns("//bibdata/date[not(@format)][@type = 'published']")) pubdate and set(:pubdate_monthyear, monthyr(pubdate.text)) end |
#committee(xml) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/isodoc/bipm/metadata.rb', line 78 def committee(xml) t = xml.at(ns(COMMITEE_XPATH)) or return n = t.at(ns("./name[@language = '#{@lang}']")) || t.at(ns("./name[not(@language)]")) n and set(:tc, n.text) end |
#configuration ⇒ Object
6 7 8 |
# File 'lib/isodoc/bipm/metadata.rb', line 6 def configuration Metanorma::Bipm.configuration end |
#docid(xml, _out) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/isodoc/bipm/metadata.rb', line 42 def docid(xml, _out) super [{ label: "level2", elem: "appendix", key: :appendixid }, { label: "level3", elem: "annexid", key: :annexid }, { label: "level4", elem: "part", key: :partid }, { label: "level5", elem: "subpart", key: :subpartid }].each do |m| docid_part(xml, [@i18n.get["#{m[:label]}_ancillary"], @i18n.get["#{m[:label]}_ancillary_alt"]], m[:elem], m[:key]) end c = xml.at(ns("#{COMMITEE_XPATH}/identifier[not(@type = 'full')][text() = 'JCGM']")) set(:org_abbrev, c ? "JCGM" : "BIPM") end |
#docid_part(isoxml, labels, elem, key) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/isodoc/bipm/metadata.rb', line 56 def docid_part(isoxml, labels, elem, key) 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
63 64 65 |
# File 'lib/isodoc/bipm/metadata.rb', line 63 def extract_person_names_affiliations() extract_person_affiliations() end |
#images(xml, out) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/isodoc/bipm/metadata.rb', line 85 def images(xml, out) super { si_aspect: "//bibdata/depiction[@type = 'si-aspect']", logo: "//bibdata/contributor[role/@type = 'publisher']/organization/logo[@type = 'full']", logo_committee: "//bibdata/contributor[role/description = 'committee']/organization/subdivision/logo" }.each do |k, v| i = xml.at(ns(v)) set(k, i ? to_xml(i.children).strip : nil) end end |
#status_print(status) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/isodoc/bipm/metadata.rb', line 30 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
20 21 22 23 24 25 26 27 28 |
# File 'lib/isodoc/bipm/metadata.rb', line 20 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
14 15 16 17 18 |
# File 'lib/isodoc/bipm/metadata.rb', line 14 def title1(xml, type, lang) xml.at(ns("//bibdata/title[@type='title-#{type}']" \ "[@language='#{lang}']")) &.children&.to_xml || "" end |