lib/asciidoctor/standoc/base.rb in metanorma-standoc-1.0.7 vs lib/asciidoctor/standoc/base.rb in metanorma-standoc-1.0.8

- old
+ new

@@ -6,10 +6,11 @@ require "open-uri" require "pp" require "sass" require "isodoc" require "relaton" +require "fileutils" module Asciidoctor module Standoc module Base Asciidoctor::Extensions.register do @@ -72,11 +73,11 @@ def doc_converter(node) IsoDoc::WordConvert.new(doc_extract_attributes(node)) end def init(node) - @fn_number = 0 + @fn_number ||= 0 @draft = false @refids = Set.new @anchors = {} @draft = node.attributes.has_key?("draft") @novalid = node.attr("novalid") @@ -96,12 +97,12 @@ unless (@no_isobib_cache || @no_isobib) globalname = bibliocache_name(true) unless node.attr("local-cache-only") localname = bibliocache_name(false) if node.attr("local-cache") || node.attr("local-cache-only") if node.attr("flush-caches") - system("rm -f #{globalname}") unless globalname.nil? - system("rm -f #{localname}") unless localname.nil? + FileUtils.rm_f globalname unless globalname.nil? + FileUtils.rm_f localname unless localname.nil? end end @bibdb = Relaton::Db.new(globalname, localname) unless @no_isobib end @@ -109,12 +110,12 @@ unless (@no_isobib_cache || @no_isobib) globalname = ievcache_name(true) unless node.attr("local-cache-only") localname = ievcache_name(false) if node.attr("local-cache") || node.attr("local-cache-only") if node.attr("flush-caches") - system("rm -f #{globalname}") unless globalname.nil? - system("rm -f #{localname}") unless localname.nil? + FileUtils.rm_f globalname unless globalname.nil? + FileUtils.rm_f localname unless localname.nil? end end @iev = Iev::Db.new(globalname, localname) unless @no_isobib end @@ -135,10 +136,10 @@ unless node.attr("nodoc") || !node.attr("docfile") File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) } html_converter(node).convert(@filename + ".xml") doc_converter(node).convert(@filename + ".xml") end - @files_to_delete.each { |f| system "rm #{f}" } + @files_to_delete.each { |f| FileUtils.rm f } ret end def makexml1(node) result = ["<?xml version='1.0' encoding='UTF-8'?>\n<standard-document>"]