Class: IsoDoc::Ieee::Metadata
- Inherits:
-
Metadata
- Object
- Metadata
- IsoDoc::Ieee::Metadata
- Defined in:
- lib/isodoc/ieee/metadata.rb
Instance Method Summary collapse
- #agency(xml) ⇒ Object
- #author(xml, _out) ⇒ Object
- #bg(xml) ⇒ Object
- #bibdate(isoxml, _out) ⇒ Object
- #coverpage_stmt(xml) ⇒ Object
- #ddMMMyyyy(isodate) ⇒ Object
- #docid(isoxml, _out) ⇒ Object
- #doctype(isoxml, _out) ⇒ Object
-
#initialize(lang, script, i18n, fonts_options = {}) ⇒ Metadata
constructor
A new instance of Metadata.
- #logos ⇒ Object
- #metadata_parse_init(isoxml) ⇒ Object
- #otherid(isoxml, _out) ⇒ Object
- #program(xml) ⇒ Object
- #society(xml) ⇒ Object
- #tc(xml) ⇒ Object
- #title(isoxml, _out) ⇒ Object
- #wg(xml) ⇒ Object
Constructor Details
#initialize(lang, script, i18n, fonts_options = {}) ⇒ Metadata
Returns a new instance of Metadata.
7 8 9 10 11 |
# File 'lib/isodoc/ieee/metadata.rb', line 7 def initialize(lang, script, i18n, = {}) super @metadata[:ieee_sasb_approveddate] = "<Date Approved>" logos end |
Instance Method Details
#agency(xml) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/isodoc/ieee/metadata.rb', line 60 def agency(xml) super logos = xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'author']/" \ "organization/logo/image/@src")) set(:corporate_author_logos, logos.map { |l| to_datauri(l.value) }) set(:corporate_author_logo_attrs, contrib_logo_attrs(xml, "author")) end |
#author(xml, _out) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/isodoc/ieee/metadata.rb', line 50 def (xml, _out) super society(xml) tc(xml) wg(xml) bg(xml) program(xml) coverpage_stmt(xml) end |
#bg(xml) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/isodoc/ieee/metadata.rb', line 100 def bg(xml) bg = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \ "organization/subdivision[@type='Balloting group']/name")) or return nil set(:balloting_group, bg.text) set(:balloting_group_type, bg.parent["subtype"]) end |
#bibdate(isoxml, _out) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/isodoc/ieee/metadata.rb', line 25 def bibdate(isoxml, _out) isoxml.xpath(ns("//bibdata/date[@format = 'ddMMMyyyy']")).each do |d| set("#{d['type'].tr('-', '_')}date".to_sym, Common::date_range(d)) end draft = isoxml.at(ns("//bibdata/date[@type = 'issued']")) || isoxml.at(ns("//bibdata/date[@type = 'circulated']")) || isoxml.at(ns("//bibdata/date[@type = 'created']")) || isoxml.at(ns("//bibdata/version/revision-date")) or return date = DateTime.parse(draft.text) set(:draft_month, date.strftime("%B")) set(:draft_year, date.strftime("%Y")) rescue StandardError end |
#coverpage_stmt(xml) ⇒ Object
68 69 70 71 |
# File 'lib/isodoc/ieee/metadata.rb', line 68 def coverpage_stmt(xml) p = xml.at(ns("//presentation-metadata/coverpage-statement")) and set(:coverpage_statement, p.children.to_xml) end |
#ddMMMyyyy(isodate) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/isodoc/ieee/metadata.rb', line 149 def ddMMMyyyy(isodate) isodate.nil? and return nil arr = isodate.split("-") if arr.size == 1 && (/^\d+$/.match isodate) Date.new(*arr.map(&:to_i)).strftime("%Y") elsif arr.size == 2 Date.new(*arr.map(&:to_i)).strftime("%b %Y") else Date.parse(isodate).strftime("%d %b %Y") end end |
#docid(isoxml, _out) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/isodoc/ieee/metadata.rb', line 115 def docid(isoxml, _out) super id = "bibdata/docidentifier[@type = 'IEEE']" dn = isoxml.at(ns("//#{id}[@scope = 'PDF']")) set(:stdid_pdf, dn&.text || "STDXXXXX") dn = isoxml.at(ns("//#{id}[@scope = 'print']")) set(:stdid_print, dn&.text || "STDPDXXXXX") dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'IEEE-draft']")) and set(:docid_draft, dn.text) dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/amendment")) and set(:amd, dn.text) dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/corrigendum")) and set(:corr, dn.text) end |
#doctype(isoxml, _out) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/isodoc/ieee/metadata.rb', line 39 def doctype(isoxml, _out) b = isoxml.at(ns("//bibdata/ext/doctype"))&.text or return set(:doctype, b.split(/[- ]/).map(&:capitalize).join(" ")) set(:doctype_abbrev, @labels["doctype_abbrev"][b]) s = isoxml.at(ns("//bibdata/ext/subdoctype"))&.text and set(:docsubtype, s.split(/[- ]/).map(&:capitalize).join(" ") .gsub(/^Icap$/, "ICAP")) s = isoxml.at(ns("//bibdata/ext/trial-use"))&.text and s == "true" and set(:trial_use, true) end |
#logos ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/isodoc/ieee/metadata.rb', line 13 def logos here = File.join(File.dirname(__FILE__), "html") suffix = ".emz" @icap and suffix = "_icap.emz" @icr and suffix = "_icr.emz" %i(wp_image001_emz wp_image003_emz wp_image007_emz wp_image008_emz) .each do |w| img = w.to_s.sub("_emz", suffix) set(w, File.(File.join(here, img))) end end |
#metadata_parse_init(isoxml) ⇒ Object
142 143 144 145 146 147 |
# File 'lib/isodoc/ieee/metadata.rb', line 142 def (isoxml) d = isoxml.at(ns("//bibdata/ext/subdoctype")) @icap = d&.text&.downcase == "icap" @icr = d&.text&.downcase == "industry-connection-report" logos end |
#otherid(isoxml, _out) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/isodoc/ieee/metadata.rb', line 107 def otherid(isoxml, _out) id = "bibdata/docidentifier[@type = 'ISBN']" dn = isoxml.at(ns("//#{id}[@scope = 'PDF']")) set(:isbn_pdf, dn&.text || "978-0-XXXX-XXXX-X") dn = isoxml.at(ns("//#{id}[@scope = 'print']")) set(:isbn_print, dn&.text || "978-0-XXXX-XXXX-X") end |
#program(xml) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/isodoc/ieee/metadata.rb', line 73 def program(xml) p = xml.at(ns("//bibdata/ext/program")) and set(:program, p.text) @icap and set(:program, "IEEE CONFORMITY ASSESSMENT PROGRAM (ICAP)") end |
#society(xml) ⇒ Object
80 81 82 83 84 85 |
# File 'lib/isodoc/ieee/metadata.rb', line 80 def society(xml) society = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \ "organization/subdivision[@type='Society']/name"))&.text || "<Society>" set(:society, society) end |
#tc(xml) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/isodoc/ieee/metadata.rb', line 87 def tc(xml) tc = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \ "organization/subdivision[@type='Committee']/name"))&.text || "<Committee Name>" set(:technical_committee, tc) end |
#title(isoxml, _out) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/isodoc/ieee/metadata.rb', line 130 def title(isoxml, _out) (isoxml) super doctype(isoxml, _out) { doctitle: "title-main", full_doctitle: "main", abbrev_doctitle: "title-abbrev", provenance_doctitle: "provenance" } .each do |k, v| t = isoxml.at(ns("//bibdata/title[@type='#{v}']")) and set(k, Common::to_xml(t.children)) end end |
#wg(xml) ⇒ Object
94 95 96 97 98 |
# File 'lib/isodoc/ieee/metadata.rb', line 94 def wg(xml) wg = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \ "organization/subdivision[@type='Working group']/name")) or return nil set(:working_group, wg.text) end |