Class: Metanorma::Plateau::Converter

Inherits:
Jis::Converter
  • Object
show all
Defined in:
lib/metanorma/plateau/log.rb,
lib/metanorma/plateau/converter.rb

Constant Summary collapse

PLATEAU_LOG_MESSAGES =
{
  # rubocop:disable Naming/VariableNumber
  "PLATEAU_1": { category: "Document Attributes",
                 error: "%s is not a recognised document type",
                 severity: 2 },
}.freeze

Instance Method Summary collapse

Instance Method Details

#default_publisherObject



17
18
19
# File 'lib/metanorma/plateau/converter.rb', line 17

def default_publisher
  "MLIT"
end

#default_requirement_modelObject



9
10
11
# File 'lib/metanorma/plateau/converter.rb', line 9

def default_requirement_model
  "ogc"
end

#doctype_validate(_xmldoc) ⇒ Object



32
33
34
35
# File 'lib/metanorma/plateau/converter.rb', line 32

def doctype_validate(_xmldoc)
  %w(handbook technical-report annex).include? @doctype or
    @log.add("PLATEAU_1", nil, params: [@doctype])
end

#html_converter(node) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/metanorma/plateau/converter.rb', line 69

def html_converter(node)
  if node.nil?
    IsoDoc::Plateau::HtmlConvert.new({})
  else
    IsoDoc::Plateau::HtmlConvert.new(html_extract_attributes(node))
  end
end

#init_metadata(node) ⇒ Object



21
22
23
24
# File 'lib/metanorma/plateau/converter.rb', line 21

def (node)
  super
  @default_doctype = "technical-report"
end

#log_messagesObject

rubocop:enable Naming/VariableNumber



12
13
14
# File 'lib/metanorma/plateau/log.rb', line 12

def log_messages
  super.merge(PLATEAU_LOG_MESSAGES)
end

#metadata_id_docidentifier(node, xml) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/metanorma/plateau/converter.rb', line 37

def (node, xml)
  id = node.attr("docidentifier")
  add_noko_elem(xml, "docidentifier", "PLATEAU #{id.sub(/^PLATEAU /, '')}",
                primary: "true",
                boilerplate: true,
                type: (node))
end

#metadata_id_primary(node, xml) ⇒ Object

do not use pubid



50
51
52
53
54
55
# File 'lib/metanorma/plateau/converter.rb', line 50

def (node, xml)
  id = node.attr("docnumber") or return
  add_noko_elem(xml, "docidentifier",
                "PLATEAU #{id.sub(/^PLATEAU /, '')}", type: "PLATEAU",
                                                      primary: "true")
end

#metadata_id_primary_type(_node) ⇒ Object



45
46
47
# File 'lib/metanorma/plateau/converter.rb', line 45

def (_node)
  "PLATEAU"
end

#metadata_stage(node, xml) ⇒ Object



67
# File 'lib/metanorma/plateau/converter.rb', line 67

def (node, xml); end

#metadata_status(node, xml) ⇒ Object

do not use pubid



58
59
60
61
62
63
64
65
# File 'lib/metanorma/plateau/converter.rb', line 58

def (node, xml)
  stage = get_stage(node)
  xml.status do |s|
    add_noko_elem(s, "stage", stage,
                  abbreviation: node.attr("docstage-abbrev"))
    add_noko_elem(s, "iteration", node.attr("iteration"))
  end
end

#org_abbrevObject



13
14
15
# File 'lib/metanorma/plateau/converter.rb', line 13

def org_abbrev
  super.merge(pub_hash["en"] => "MLIT")
end

#pdf_converter(node) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/metanorma/plateau/converter.rb', line 77

def pdf_converter(node)
  return if node.attr("no-pdf")

  if node.nil?
    IsoDoc::Plateau::PdfConvert.new({})
  else
    IsoDoc::Plateau::PdfConvert.new(pdf_extract_attributes(node))
  end
end

#presentation_xml_converter(node) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/metanorma/plateau/converter.rb', line 87

def presentation_xml_converter(node)
  if node.nil?
    IsoDoc::Plateau::PresentationXMLConvert.new({})
  else
    IsoDoc::Plateau::PresentationXMLConvert
      .new(doc_extract_attributes(node)
      .merge(output_formats: ::Metanorma::Plateau::Processor.new
        .output_formats))
  end
end

#pub_hashObject

Plateau reuse of the JIS publisher default setting



27
28
29
30
# File 'lib/metanorma/plateau/converter.rb', line 27

def pub_hash
  { "ja" => "国土交通省",
    "en" => "Ministry of Land, Infrastructure, Transport and Tourism" }
end