Module: Metanorma::Compile::Extract

Extended by:
Writeable
Defined in:
lib/metanorma/compile/extract.rb

Class Method Summary collapse

Methods included from Writeable

export_output

Class Method Details

.extract(isodoc, dirname, extract_types) ⇒ void

This method returns an undefined value.

Parameters:

  • isodoc (String)

    the XML document

  • dirname (String, nil)

    the directory to extract to

  • extract_types (Array<Symbol>, nil)

    the types to extract



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/metanorma/compile/extract.rb', line 12

def self.extract(isodoc, dirname, extract_types)
  dirname or return
  extract_types.nil? || extract_types.empty? and
    extract_types = %i[sourcecode image requirement]
  FileUtils.rm_rf dirname
  FileUtils.mkdir_p dirname
  xml = Nokogiri::XML(isodoc, &:huge)
  extract_types.each do |type|
    case type
    when :sourcecode
      export_sourcecode(xml, dirname)
    when :image
      export_image(xml, dirname)
    when :requirement
      export_requirement(xml, dirname)
    end
  end
end