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

def initialize(lang, script, i18n, fonts_options = {})
  super
  @metadata[:confirmeddate] = "<Date Approved>"
end

Instance Method Details

#author(xml, _out) ⇒ Object



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

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

#bg(xml) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/isodoc/ieee/metadata.rb', line 83

def bg(xml)
  bg = xml.at(ns("//bibdata/ext/editorialgroup/"\
                 "balloting-group")) or return nil
  set(:balloting_group, bg.text)
  m = {}
  m["members"] = editor_names(xml, "Balloting Group Member")
  m["members"].empty? and (1..9).each do |i|
    m["members"] << "Balloter#{i}"
  end
  set(:balloting_group_members, m["members"])
end

#bibdate(isoxml, _out) ⇒ Object



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

def bibdate(isoxml, _out)
  super
  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

#docid(isoxml, _out) ⇒ Object



116
117
118
119
120
121
122
123
# File 'lib/isodoc/ieee/metadata.rb', line 116

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")
end

#doctype(isoxml, _out) ⇒ Object



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

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/docsubtype"))&.text and
    set(:docsubtype, s.split(/[- ]/).map(&:capitalize).join(" "))
end

#editor_name(xml, role) ⇒ Object



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

def editor_name(xml, role)
  editor_names(xml, role)&.first
end

#editor_names(xml, role) ⇒ Object



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

def editor_names(xml, role)
  xml.xpath(ns("//bibdata/contributor[role/@type = 'editor']"\
               "[role = '#{role}']/person/name/completename"))
    &.each&.map(&:text)
end

#otherid(isoxml, _out) ⇒ Object



108
109
110
111
112
113
114
# File 'lib/isodoc/ieee/metadata.rb', line 108

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

#society(xml) ⇒ Object



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

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

#std_group(xml) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/isodoc/ieee/metadata.rb', line 95

def std_group(xml)
  m = {}
  ["Chair", "Vice-Chair", "Past Chair", "Secretary"].each do |r|
    m[r.downcase.gsub(/ /, "-")] =
      editor_name(xml, "Standards Board #{r}") || "&lt;Name&gt;"
  end
  m["members"] = editor_names(xml, "Standards Board Member")
  m["members"].empty? and (1..9).each do |i|
    m["members"] << "SBMember#{i}"
  end
  set(:std_board, m)
end

#tc(xml) ⇒ Object



47
48
49
50
51
# File 'lib/isodoc/ieee/metadata.rb', line 47

def tc(xml)
  tc = xml.at(ns("//bibdata/ext/editorialgroup/"\
                 "technical-committee"))&.text || "&lt;Committee Name&gt;"
  set(:technical_committee, tc)
end

#title(isoxml, _out) ⇒ Object



125
126
127
128
129
130
131
132
133
# File 'lib/isodoc/ieee/metadata.rb', line 125

def title(isoxml, _out)
  super
  draft = isoxml&.at(ns("//bibdata/version/draft"))
  doctype(isoxml, _out)
  title = "#{@metadata[:doctype_abbrev] || '???'} for "\
          "#{@metadata[:doctitle] || '???'}"
  draft and title = "Draft #{title}"
  set(:full_doctitle, title)
end

#wg(xml) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/isodoc/ieee/metadata.rb', line 63

def wg(xml)
  wg = xml.at(ns("//bibdata/ext/editorialgroup/"\
                 "working-group")) or return nil
  set(:working_group, wg.text)
  m = {}
  ["Chair", "Vice-Chair", "Secretary"].each do |r|
    a = editor_name(xml, "Working Group #{r}") and
      m[r.downcase.gsub(/ /, "-")] = a
  end
  wg_members(xml, m)
end

#wg_members(xml, members) ⇒ Object



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

def wg_members(xml, members)
  a = editor_names(xml, "Working Group Member") and members["members"] = a
  members["members"].empty? and (1..9).each do |i|
    members["members"] << "Participant#{i}"
  end
  set(:wg_members, members)
end