diff --git a/engines/lualatex.rb b/engines/lualatex.rb index 4bcbfeb..adfbb2c 100644 --- a/engines/lualatex.rb +++ b/engines/lualatex.rb @@ -39,7 +39,7 @@ def hash_result without: /\/CreationDate|\/ModDate|\/ID|\/Type\/XRef\/Index/) end - def exec() + def exec @old_hash = hash_result # Command for the main LaTeX compilation work @@ -49,7 +49,7 @@ def exec() f = IO::popen(eval(lualatex)) log = f.readlines.map! { |s| Log.fix(s) } - [File.exist?(@target_file), TeXLogParser.parse(log), log.join('').strip!] + { success: File.exist?(@target_file), messages: TeXLogParser.parse(log), log: log.join('').strip! } end end diff --git a/engines/pdflatex.rb b/engines/pdflatex.rb index 1962a1d..39d3715 100644 --- a/engines/pdflatex.rb +++ b/engines/pdflatex.rb @@ -38,7 +38,7 @@ def hash_result HashManager.hash_file(@target_file, without: /\/CreationDate|\/ModDate|\/ID/) end - def exec() + def exec @old_hash = hash_result # Command for the main LaTeX compilation work @@ -48,7 +48,7 @@ def exec() f = IO::popen(eval(pdflatex)) log = f.readlines.map! { |s| Log.fix(s) } - [File.exist?(@target_file), TeXLogParser.parse(log), log.join('').strip!] + { success: File.exist?(@target_file), messages: TeXLogParser.parse(log), log: log.join('').strip! } end end diff --git a/engines/xelatex.rb b/engines/xelatex.rb index 8c8b9ce..302f104 100644 --- a/engines/xelatex.rb +++ b/engines/xelatex.rb @@ -38,7 +38,7 @@ def hash_result HashManager.hash_file(@target_file, drop_from: /CIDFontType0C|Type1C/) end - def exec() + def exec @old_hash = hash_result # Command for the main LaTeX compilation work @@ -48,7 +48,7 @@ def exec() f = IO::popen(eval(xelatex)) log = f.readlines.map! { |s| Log.fix(s) } - [File.exist?(@target_file), TeXLogParser.parse(log), log.join('').strip!] + { success: File.exist?(@target_file), messages: TeXLogParser.parse(log), log: log.join('').strip! } end end diff --git a/lib/Engine.rb b/lib/Engine.rb index 07129df..0acefd4 100644 --- a/lib/Engine.rb +++ b/lib/Engine.rb @@ -56,17 +56,17 @@ def initialize public # Returns true iff this engine needs to run (again) - def do?() + def do? false end # Executes this engine - # Returns an array with three elements - # 1. true iff there were no fatal errors - # 2. A list of log messages (cf LogMessage) - # 3. The raw output of the external program - def exec() - [true, ['No execution code, need to overwrite!'], 'No execution code, need to overwrite!'] + # Returns a dictionary with three entries: + # - sucess: true iff there were no fatal errors + # - messages: A list of log messages (cf LogMessage) + # - log: The raw output of the external program + def exec + { success: true, messages: ['No execution code, need to overwrite!'], log: 'No execution code, need to overwrite!' } end def name diff --git a/ltx2any.rb b/ltx2any.rb index 4a901cb..6034e79 100644 --- a/ltx2any.rb +++ b/ltx2any.rb @@ -181,9 +181,9 @@ # Run engine OUTPUT.start("#{engine.name}(#{run}) running") result = engine.exec - OUTPUT.stop(if result[0] then :success else :error end) + OUTPUT.stop(if result[:success] then :success else :error end) - break if !File.exist?("#{PARAMS[:jobname]}.#{engine.extension}") + break unless File.exist?("#{PARAMS[:jobname]}.#{engine.extension}") # Run extensions that need to do something after this iteration Extension.run_all(run, OUTPUT, log) @@ -194,7 +194,7 @@ end # Save log messages of last engine run - log.add_messages(engine.name, :engine, result[1], result[2]) + log.add_messages(engine.name, :engine, result[:messages], result[:log]) # Run extensions that may need to do something after all engine runs Extension.run_all(:after, OUTPUT, log)