Class: IsoDoc::Ieee::Metadata

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

Instance Method Summary collapse

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, fonts_options = {})
  super
  @metadata[:issueddate] = "<Date Approved>"
  logos
end

Instance Method Details

#author(xml, _out) ⇒ Object



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

def author(xml, _out)
  super
  society(xml)
  tc(xml)
  wg(xml)
  bg(xml)
  program(xml)
end

#bg(xml) ⇒ Object



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

def bg(xml)
  bg = xml.at(ns("//bibdata/ext/editorialgroup/" \
                 "balloting-group")) or return nil
  set(:balloting_group, bg.text)
  set(:balloting_group_type, bg["type"])
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

#ddMMMyyyy(isodate) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/isodoc/ieee/metadata.rb', line 136

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



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/isodoc/ieee/metadata.rb', line 99

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/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

#fulltitle(type, draft) ⇒ Object



123
124
125
126
127
# File 'lib/isodoc/ieee/metadata.rb', line 123

def fulltitle(type, draft)
  title = "#{type || '???'} for #{@metadata[:doctitle] || '???'}"
  draft and title = "Draft #{title}"
  title
end

#logosObject



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.expand_path(File.join(here, img)))
  end
end

#metadata_parse_init(isoxml) ⇒ Object



129
130
131
132
133
134
# File 'lib/isodoc/ieee/metadata.rb', line 129

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



91
92
93
94
95
96
97
# File 'lib/isodoc/ieee/metadata.rb', line 91

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



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

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



66
67
68
69
70
# File 'lib/isodoc/ieee/metadata.rb', line 66

def society(xml)
  society = xml.at(ns("//bibdata/ext/editorialgroup/" \
                      "society"))&.text || "<Society>"
  set(:society, society)
end

#tc(xml) ⇒ Object



72
73
74
75
76
# File 'lib/isodoc/ieee/metadata.rb', line 72

def tc(xml)
  tc = xml.at(ns("//bibdata/ext/editorialgroup/" \
                 "committee"))&.text || "<Committee Name>"
  set(:technical_committee, tc)
end

#title(isoxml, _out) ⇒ Object



112
113
114
115
116
117
118
119
120
121
# File 'lib/isodoc/ieee/metadata.rb', line 112

def title(isoxml, _out)
  (isoxml)
  super
  draft = isoxml.at(ns("//bibdata/version/draft"))
  doctype(isoxml, _out)
  set(:full_doctitle, fulltitle(@metadata[:doctype], draft))
  set(:abbrev_doctitle, fulltitle(@metadata[:doctype_abbrev], draft))
  prov = isoxml.at(ns("//bibdata/title[@type='provenance']")) and
    set(:provenance_doctitle, Common::to_xml(prov.children))
end

#wg(xml) ⇒ Object



78
79
80
81
82
# File 'lib/isodoc/ieee/metadata.rb', line 78

def wg(xml)
  wg = xml.at(ns("//bibdata/ext/editorialgroup/" \
                 "working-group")) or return nil
  set(:working_group, wg.text)
end