-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applies a number of auto-fixes from RubyMine/RuboCop. Pertains to issue #93.
- Loading branch information
Showing
31 changed files
with
1,119 additions
and
1,145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Metrics/LineLength: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2016, Raphael Reitzig | ||
# Copyright 2010-2018, Raphael Reitzig | ||
# <[email protected]> | ||
# | ||
# This file is part of ltx2any. | ||
|
@@ -18,35 +18,36 @@ | |
|
||
Dependency.new('lualatex', :binary, [:engine, 'lualatex'], :essential) | ||
|
||
# TODO: document | ||
class LuaLaTeX < Engine | ||
|
||
def initialize | ||
super | ||
@binary = 'lualatex' | ||
@extension = 'pdf' | ||
@description = 'Uses LuaLaTeX to create a PDF' | ||
|
||
@target_file = "#{ParameterManager.instance[:jobname]}.#{extension}" | ||
@old_hash = hash_result | ||
end | ||
|
||
def do? | ||
!File.exist?(@target_file) || hash_result != @old_hash | ||
end | ||
|
||
def hash_result | ||
HashManager.hash_file(@target_file, | ||
HashManager.hash_file(@target_file, | ||
without: /\/CreationDate|\/ModDate|\/ID|\/Type\/XRef\/Index/) | ||
end | ||
|
||
def exec | ||
@old_hash = hash_result | ||
|
||
# Command for the main LaTeX compilation work | ||
params = ParameterManager.instance | ||
lualatex = '"lualatex -file-line-error -interaction=nonstopmode #{params[:enginepar]} \"#{params[:jobfile]}\""' | ||
|
||
f = IO::popen(eval(lualatex)) | ||
f = IO.popen(eval(lualatex)) | ||
log = f.readlines.map! { |s| Log.fix(s) } | ||
|
||
{ success: File.exist?(@target_file), messages: TeXLogParser.parse(log), log: log.join('').strip! } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2016, Raphael Reitzig | ||
# Copyright 2010-2018, Raphael Reitzig | ||
# <[email protected]> | ||
# | ||
# This file is part of ltx2any. | ||
|
@@ -18,22 +18,23 @@ | |
|
||
Dependency.new('pdflatex', :binary, [:engine, 'pdflatex'], :essential) | ||
|
||
class PdfLaTeX < Engine | ||
# TODO: document | ||
class PdfLaTeX < Engine | ||
|
||
def initialize | ||
super | ||
@binary = 'pdflatex' | ||
@extension = 'pdf' | ||
@description = 'Uses PdfLaTeX to create a PDF' | ||
|
||
@target_file = "#{ParameterManager.instance[:jobname]}.#{extension}" | ||
@old_hash = hash_result | ||
end | ||
|
||
def do? | ||
!File.exist?(@target_file) || hash_result != @old_hash | ||
end | ||
|
||
def hash_result | ||
HashManager.hash_file(@target_file, without: /\/CreationDate|\/ModDate|\/ID/) | ||
end | ||
|
@@ -45,7 +46,7 @@ def exec | |
params = ParameterManager.instance | ||
pdflatex = '"pdflatex -file-line-error -interaction=nonstopmode #{params[:enginepar]} \"#{params[:jobfile]}\""' | ||
|
||
f = IO::popen(eval(pdflatex)) | ||
f = IO.popen(eval(pdflatex)) | ||
log = f.readlines.map! { |s| Log.fix(s) } | ||
|
||
{ success: File.exist?(@target_file), messages: TeXLogParser.parse(log), log: log.join('').strip! } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2016, Raphael Reitzig | ||
# Copyright 2010-2018, Raphael Reitzig | ||
# <[email protected]> | ||
# | ||
# This file is part of ltx2any. | ||
|
@@ -18,34 +18,34 @@ | |
|
||
Dependency.new('xelatex', :binary, [:engine, 'xelatex'], :essential) | ||
|
||
# TODO: document | ||
class XeLaTeX < Engine | ||
|
||
def initialize | ||
super | ||
@binary = 'xelatex' | ||
@extension = 'pdf' | ||
@description = 'Uses XeLaTeX to create a PDF' | ||
|
||
@target_file = "#{ParameterManager.instance[:jobname]}.#{extension}" | ||
@old_hash = hash_result | ||
end | ||
|
||
def do? | ||
!File.exist?(@target_file) || hash_result != @old_hash | ||
end | ||
|
||
def hash_result | ||
HashManager.hash_file(@target_file, drop_from: /CIDFontType0C|Type1C/) | ||
end | ||
|
||
def exec | ||
@old_hash = hash_result | ||
|
||
# Command for the main LaTeX compilation work | ||
params = ParameterManager.instance | ||
xelatex = '"xelatex -file-line-error -interaction=nonstopmode #{params[:enginepar]} \"#{params[:jobfile]}\""' | ||
|
||
f = IO::popen(eval(xelatex)) | ||
f = IO.popen(eval(xelatex)) | ||
log = f.readlines.map! { |s| Log.fix(s) } | ||
|
||
{ success: File.exist?(@target_file), messages: TeXLogParser.parse(log), log: log.join('').strip! } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2016, Raphael Reitzig | ||
# Copyright 2010-2018, Raphael Reitzig | ||
# <[email protected]> | ||
# | ||
# This file is part of ltx2any. | ||
|
@@ -18,6 +18,7 @@ | |
|
||
Dependency.new('biber', :binary, [:extension, 'Biber'], :essential) | ||
|
||
# TODO: document | ||
class Biber < Extension | ||
def initialize | ||
super | ||
|
@@ -28,12 +29,12 @@ def initialize | |
|
||
def do?(time) | ||
return false unless time == 1 | ||
|
||
params = ParameterManager.instance | ||
|
||
usesbib = File.exist?("#{params[:jobname]}.bcf") | ||
needrerun = false | ||
|
||
if usesbib | ||
# Collect sources (needed for log parsing) | ||
@sources = [] | ||
|
@@ -43,8 +44,8 @@ def do?(time) | |
end | ||
} | ||
@sources.uniq! | ||
|
||
|
||
# Aside from the first run (no bbl), | ||
# there are two things that prompt us to rerun: | ||
# * changes to the bcf file (which includes all kinds of things, | ||
|
@@ -53,21 +54,21 @@ def do?(time) | |
needrerun = !File.exist?("#{params[:jobname]}.bbl") | # Is this the first run? | ||
HashManager.instance.files_changed?("#{params[:jobname]}.bcf", | ||
*@sources) | ||
# Note: non-strict OR so that hashes are computed for next run | ||
# Note: non-strict OR so that hashes are computed for next run | ||
end | ||
|
||
usesbib && needrerun | ||
end | ||
|
||
def exec(time, progress) | ||
params = ParameterManager.instance | ||
|
||
# Command to process bibtex bibliography if necessary. | ||
# Uses the following variables: | ||
# * jobname -- name of the main LaTeX file (without file ending) | ||
biber = '"biber \"#{params[:jobname]}\""' | ||
|
||
f = IO::popen(eval(biber)) | ||
f = IO.popen(eval(biber)) | ||
log = f.readlines | ||
|
||
# Dig trough output and find errors | ||
|
@@ -92,5 +93,5 @@ def exec(time, progress) | |
{ success: !errors, messages: msgs, log: log.join('').strip! } | ||
end | ||
end | ||
|
||
Extension.add Biber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2016, Raphael Reitzig | ||
# Copyright 2010-2018, Raphael Reitzig | ||
# <[email protected]> | ||
# | ||
# This file is part of ltx2any. | ||
|
@@ -18,48 +18,49 @@ | |
|
||
Dependency.new('bibtex', :binary, [:extension, 'BibTeX'], :essential) | ||
|
||
# TODO: document | ||
class BibTeX < Extension | ||
def initialize | ||
super | ||
super | ||
@name = 'BibTeX' | ||
@description = 'Creates bibliographies (old)' | ||
# For checking whether bibtex has to rerun, we need to keep the | ||
|
||
# For checking whether bibtex has to rerun, we need to keep the | ||
# relevant parts of the _.aux file handy. | ||
# TODO use internal store? | ||
@grepfile = 'bibtex_aux_grep' | ||
end | ||
|
||
def do?(time) | ||
return false unless time == 1 | ||
|
||
params = ParameterManager.instance | ||
|
||
# Collect used bibdata files and style file | ||
stylefile = [] | ||
bibdata = [] | ||
grepdata = [] | ||
if File.exist?("#{params[:jobname]}.aux") | ||
File.open("#{params[:jobname]}.aux", 'r') { |file| | ||
while ( line = file.gets ) | ||
if /^\\bibdata\{(.+?)\}$/ =~ line | ||
if /^\\bibdata{(.+?)}$/ =~ line | ||
# If commas occur, add both a split version (multiple files) | ||
# and the hole string (filename with comma), to be safe. | ||
bibdata += $~[1].split(',').map { |s| "#{s}.bib" } + [$~[1]] | ||
grepdata.push line.strip | ||
elsif /^\\bibstyle\{(.+?)\}$/ =~ line | ||
grepdata.push line.strip | ||
elsif /^\\bibstyle{(.+?)}$/ =~ line | ||
stylefile.push "#{$~[1]}.bst" | ||
grepdata.push line.strip | ||
grepdata.push line.strip | ||
elsif /^\\(bibcite|citation)/ =~ line | ||
grepdata.push line.strip | ||
end | ||
grepdata.push line.strip | ||
end | ||
end | ||
} | ||
end | ||
end | ||
|
||
# Check whether bibtex is necessary at all | ||
usesbib = bibdata.size > 0 | ||
usesbib = !bibdata.empty? | ||
|
||
# Write relevant part of the _.aux file into a separate file for hashing | ||
if usesbib | ||
File.open(@grepfile, 'w') { |f| | ||
|
@@ -78,13 +79,13 @@ def do?(time) | |
|
||
def exec(time, progress) | ||
params = ParameterManager.instance | ||
|
||
# Command to process bibtex bibliography if necessary. | ||
# Uses the following variables: | ||
# * jobname -- name of the main LaTeX file (without file ending) | ||
bibtex = '"bibtex \"#{params[:jobname]}\""' | ||
|
||
f = IO::popen(eval(bibtex)) | ||
f = IO.popen(eval(bibtex)) | ||
log = f.readlines | ||
|
||
# Dig trough output and find errors | ||
|
@@ -103,7 +104,7 @@ def exec(time, progress) | |
msg = lastline | ||
logline = [linectr - 1, linectr] | ||
end | ||
|
||
msgs.push(LogMessage.new(:error, $~[3], [Integer($~[2])], logline, msg)) | ||
errors = true | ||
end | ||
|
@@ -114,5 +115,5 @@ def exec(time, progress) | |
{ success: !errors, messages: msgs, log: log.join('').strip! } | ||
end | ||
end | ||
|
||
Extension.add BibTeX |
Oops, something went wrong.