Class: Metanorma::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/processor.rb,
lib/metanorma/processor/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.



8
9
10
# File 'lib/metanorma/processor/processor.rb', line 8

def initialize
  raise "This is an abstract class!"
end

Instance Attribute Details

#asciidoctor_backendObject (readonly)

Returns the value of attribute asciidoctor_backend.



6
7
8
# File 'lib/metanorma/processor/processor.rb', line 6

def asciidoctor_backend
  @asciidoctor_backend
end

#input_formatObject (readonly)

Returns the value of attribute input_format.



6
7
8
# File 'lib/metanorma/processor/processor.rb', line 6

def input_format
  @input_format
end

#shortObject (readonly)

Returns the value of attribute short.



6
7
8
# File 'lib/metanorma/processor/processor.rb', line 6

def short
  @short
end

Instance Method Details

#extract_metanorma_options(file) ⇒ Object



50
51
52
# File 'lib/metanorma/processor/processor.rb', line 50

def extract_metanorma_options(file)
  Metanorma::Input::Asciidoc.new.extract_metanorma_options(file)
end

#extract_options(file) ⇒ Object



45
46
47
48
# File 'lib/metanorma/processor/processor.rb', line 45

def extract_options(file)
  Metanorma::Input::Asciidoc.new.extract_options(file)
    .merge(output_formats: output_formats)
end

#input_to_isodoc(file, filename, options = {}) ⇒ Object



20
21
22
23
# File 'lib/metanorma/processor/processor.rb', line 20

def input_to_isodoc(file, filename, options = {})
  Metanorma::Input::Asciidoc.new.process(file, filename,
                                         @asciidoctor_backend, options)
end

#options_preprocess(options) ⇒ Object



37
38
39
# File 'lib/metanorma/processor/processor.rb', line 37

def options_preprocess(options)
  options[:output_formats] ||= output_formats
end

#output(isodoc_node, _inname, outname, _format, _options = {}) ⇒ Object



41
42
43
# File 'lib/metanorma/processor/processor.rb', line 41

def output(isodoc_node, _inname, outname, _format, _options = {})
  File.open(outname, "w:UTF-8") { |f| f.write(isodoc_node) }
end

#output_formatsObject



12
13
14
15
16
17
18
# File 'lib/metanorma/processor/processor.rb', line 12

def output_formats
  {
    xml: "xml",
    presentation: "presentation.xml",
    rxl: "rxl",
  }
end

#use_presentation_xml(ext) ⇒ Object

def input_to_isodoc(file, filename)

raise "This is an abstract class!"

end



29
30
31
32
33
34
35
# File 'lib/metanorma/processor/processor.rb', line 29

def use_presentation_xml(ext)
  case ext
  when :html, :doc, :pdf then true
  else
    false
  end
end