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
  [:issueddate] = "<Date Approved>"
  logos
end

Instance Method Details

#author(xml, _out) ⇒ Object



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

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

#bg(xml) ⇒ Object



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

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



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/isodoc/ieee/metadata.rb', line 34

def bibdate(isoxml, _out)
  isoxml.xpath(ns("//bibdata/date[@format = 'ddMMMyyyy']")).each do |d|
    set("#{d['type'].gsub('-', '_')}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



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/isodoc/ieee/metadata.rb', line 145

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



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/isodoc/ieee/metadata.rb', line 108

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



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

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



132
133
134
135
136
# File 'lib/isodoc/ieee/metadata.rb', line 132

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
# File 'lib/isodoc/ieee/metadata.rb', line 13

def logos
  here = File.join(File.dirname(__FILE__), "html")
  i(wp_image001_emz wp_image003_emz wp_image008_emz)
    .each do |w|
    img = w.to_s.sub("_emz", ".emz")
    set(w, File.expand_path(File.join(here, img)))
  end
end

#metadata_parse_init(isoxml) ⇒ Object



138
139
140
141
142
143
# File 'lib/isodoc/ieee/metadata.rb', line 138

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



100
101
102
103
104
105
106
# File 'lib/isodoc/ieee/metadata.rb', line 100

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



68
69
70
71
72
73
# File 'lib/isodoc/ieee/metadata.rb', line 68

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



75
76
77
78
79
# File 'lib/isodoc/ieee/metadata.rb', line 75

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

#tc(xml) ⇒ Object



81
82
83
84
85
# File 'lib/isodoc/ieee/metadata.rb', line 81

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

#title(isoxml, _out) ⇒ Object



121
122
123
124
125
126
127
128
129
130
# File 'lib/isodoc/ieee/metadata.rb', line 121

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

#wg(xml) ⇒ Object



87
88
89
90
91
# File 'lib/isodoc/ieee/metadata.rb', line 87

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