Skip to content

Commit

Permalink
Engine.exec now uses a dictionary for return values, no unreadable ar…
Browse files Browse the repository at this point in the history
…ray; cf issue #93.
  • Loading branch information
akerbos committed Feb 11, 2017
1 parent 2def4ff commit 4975e0a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions engines/lualatex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions engines/pdflatex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions engines/xelatex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
14 changes: 7 additions & 7 deletions lib/Engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ltx2any.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 4975e0a

Please sign in to comment.