Module: Asciidoctor::ISO::Front

Included in:
Converter
Defined in:
lib/asciidoctor/iso/front.rb

Instance Method Summary collapse

Instance Method Details

#committee_component(compname, node, out) ⇒ Object



31
32
33
34
35
# File 'lib/asciidoctor/iso/front.rb', line 31

def committee_component(compname, node, out)
  out.send compname.gsub(/-/, "_"), node.attr(compname),
    **attr_code(number: node.attr("#{compname}-number"),
                type: node.attr("#{compname}-type"))
end

#metadata(node, xml) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/asciidoctor/iso/front.rb', line 99

def (node, xml)
  title node, xml
  (node, xml)
  (node, xml)
  (node, xml)
  xml.language node.attr("language")
  xml.script (node.attr("script") || "Latn")
  (node, xml)
  (node, xml)
  (node, xml)
end

#metadata_author(node, xml) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/asciidoctor/iso/front.rb', line 51

def (node, xml)
  publishers = node.attr("publisher") || "ISO"
  publishers.split(/,[ ]?/).each do |p|
    xml.contributor do |c|
      c.role **{ type: "author" }
      c.organization { |a| organization(a, p) }
    end
  end
end

#metadata_committee(node, xml) ⇒ Object



90
91
92
93
94
95
96
97
# File 'lib/asciidoctor/iso/front.rb', line 90

def (node, xml)
  xml.editorialgroup do |a|
    committee_component("technical-committee", node, a)
    committee_component("subcommittee", node, a)
    committee_component("workgroup", node, a)
    node.attr("secretariat") && a.secretariat(node.attr("secretariat"))
  end
end


71
72
73
74
75
76
77
78
79
80
81
# File 'lib/asciidoctor/iso/front.rb', line 71

def (node, xml)
  publishers = node.attr("publisher") || "ISO"
  publishers.split(/,[ ]?/).each do |p|
    xml.copyright do |c|
      c.from (node.attr("copyright-year") || Date.today.year)
      c.owner do |owner|
        owner.organization { |o| organization(o, p) }
      end
    end
  end
end

#metadata_id(node, xml) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/asciidoctor/iso/front.rb', line 12

def (node, xml)
  part, subpart = node&.attr("partnumber")&.split(/-/)
  xml.docidentifier do |i|
    i.project_number node.attr("docnumber"),
      **attr_code(part: part, subpart: subpart)
    if node.attr("tc-docnumber")
      i.tc_document_number node.attr("tc-docnumber")
    end
  end
end

#metadata_publisher(node, xml) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/asciidoctor/iso/front.rb', line 61

def (node, xml)
  publishers = node.attr("publisher") || "ISO"
  publishers.split(/,[ ]?/).each do |p|
    xml.contributor do |c|
      c.role **{ type: "publisher" }
      c.organization { |a| organization(a, p) }
    end
  end
end

#metadata_status(node, xml) ⇒ Object



83
84
85
86
87
88
# File 'lib/asciidoctor/iso/front.rb', line 83

def (node, xml)
  xml.status do |s|
    s.stage (node.attr("docstage") || "60")
    s.substage (node.attr("docsubstage") || "60")
  end
end

#metadata_version(node, xml) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/asciidoctor/iso/front.rb', line 23

def (node, xml)
  xml.version do |v|
    v.edition node.attr("edition") if node.attr("edition")
    v.revision_date node.attr("revdate") if node.attr("revdate")
    v.draft node.attr("draft") if node.attr("draft")
  end
end

#organization(org, orgname) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/asciidoctor/iso/front.rb', line 37

def organization(org, orgname)
  if ["ISO",
      "International Organization for Standardization"].include? orgname
    org.name "International Organization for Standardization"
    org.abbreviation "ISO"
  elsif ["IEC", 
           "International Electrotechnical Commission"].include? orgname
    org.name "International Electrotechnical Commission"
    org.abbreviation "IEC"
  else
    org.name orgname
  end
end

#title(node, xml) ⇒ Object



131
132
133
134
135
136
137
138
139
140
# File 'lib/asciidoctor/iso/front.rb', line 131

def title(node, xml)
  ["en", "fr"].each do |lang|
    xml.title do |t|
      at = { language: lang, format: "text/plain" }
      title_intro(node, t, lang, at)
      title_main(node, t, lang, at)
      title_part(node, t, lang, at)
    end
  end
end

#title_intro(node, t, lang, at) ⇒ Object



111
112
113
114
115
116
# File 'lib/asciidoctor/iso/front.rb', line 111

def title_intro(node, t, lang, at)
  return unless node.attr("title-intro-#{lang}")
  t.title_intro(**attr_code(at)) do |t1|
    t1 << node.attr("title-intro-#{lang}")
  end
end

#title_main(node, t, lang, at) ⇒ Object



118
119
120
121
122
# File 'lib/asciidoctor/iso/front.rb', line 118

def title_main(node, t, lang, at)
  t.title_main **attr_code(at) do |t1|
    t1 << node.attr("title-main-#{lang}")
  end
end

#title_part(node, t, lang, at) ⇒ Object



124
125
126
127
128
129
# File 'lib/asciidoctor/iso/front.rb', line 124

def title_part(node, t, lang, at)
  return unless node.attr("title-part-#{lang}")
  t.title_part(**attr_code(at)) do |t1|
    t1 << node.attr("title-part-#{lang}")
  end
end