wortsammler 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wortsammler/class.Traceable.md.rb +90 -90
- data/lib/wortsammler/class.Traceable.rb +4 -2
- data/lib/wortsammler/class.proolib.rb +39 -17
- data/lib/wortsammler/exe.wortsammler.rb +5 -5
- data/lib/wortsammler/latex_helper.rb +244 -0
- data/lib/wortsammler/version.rb +1 -1
- data/lib/wortsammler.rb +30 -14
- data/resources/default.wortsammler.latex +4 -0
- data/spec/test_mkindex.md +22 -0
- data/spec/wortsammler_spec.rb +42 -10
- data/testresults/wortsammler_testresults.html +129 -121
- data/testresults/wortsammler_testresults.log +12 -8
- data/wortsammler.gemspec +1 -1
- metadata +6 -3
@@ -11,98 +11,98 @@ Treetop.load File.dirname(__FILE__) + "/mdTraceParser.treetop"
|
|
11
11
|
|
12
12
|
|
13
13
|
class TraceableSet
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# this generates a synopsis of traces in markdown Format
|
18
|
-
# @param [Symbol] selectedCategory the the category of the Traceables
|
19
|
-
# which shall be reported.
|
20
|
-
def reqtraceSynopsis(selectedCategory)
|
21
|
-
all_traces(selectedCategory).
|
22
|
-
sort_by{|x| trace_order_index(x.id) }.
|
23
|
-
map{|t|
|
24
|
-
tidm=t.id.gsub("_","-")
|
25
|
-
|
26
|
-
lContributes=t.contributes_to.
|
27
|
-
# map{|c| cm=c.gsub("_","-"); "[\[#{c}\]](#RT-#{cm})"}
|
28
|
-
map{|c| cm=c.gsub("_","-"); "<a href=\"#RT-#{cm}\">\[#{c}\]</a>"}
|
29
|
-
|
30
|
-
luptraces = [uptrace_ids[t.id]].flatten.compact.map{|x| self[x]}
|
31
|
-
|
32
|
-
luptraces=luptraces.
|
33
|
-
sort_by{|x| trace_order_index(x.id)}.
|
34
|
-
map{|u|
|
35
|
-
um = u.id.gsub("_","-")
|
36
|
-
" - <a href=\"#RT-#{um}\">[#{u.id}]</a> #{u.header_orig}"
|
37
|
-
}
|
38
|
-
|
39
|
-
["- ->[#{t.id}] <!-- --> <a id=\"RT-#{tidm}\"/>**#{t.header_orig}**" +
|
40
|
-
# " (#{t.contributes_to.join(', ')})", "",
|
41
|
-
" (#{lContributes.join(', ')})", "",
|
42
|
-
luptraces
|
43
|
-
].flatten.join("\n")
|
44
|
-
}.join("\n\n")
|
45
|
-
end
|
46
14
|
|
47
15
|
|
48
|
-
# this generates the downstream_tracefile
|
49
|
-
def to_downstream_tracefile(selectedCategory)
|
50
|
-
all_traces(selectedCategory).
|
51
|
-
sort_by{|x| trace_order_index(x.id) }.
|
52
|
-
map{|t|
|
53
|
-
"\n\n[#{t.id}] **#{t.header_orig}** { }()"
|
54
|
-
}.join("\n\n")
|
55
|
-
end
|
56
16
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
#
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
#
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
17
|
+
# this generates a synopsis of traces in markdown Format
|
18
|
+
# @param [Symbol] selectedCategory the the category of the Traceables
|
19
|
+
# which shall be reported.
|
20
|
+
def reqtraceSynopsis(selectedCategory)
|
21
|
+
all_traces(selectedCategory).
|
22
|
+
sort_by{|x| trace_order_index(x.id) }.
|
23
|
+
map{|t|
|
24
|
+
tidm=t.id.gsub("_","-")
|
25
|
+
|
26
|
+
lContributes=t.contributes_to.
|
27
|
+
# map{|c| cm=c.gsub("_","-"); "[\[#{c}\]](#RT-#{cm})"}
|
28
|
+
map{|c| cm=c.gsub("_","-"); "<a href=\"#RT-#{cm}\">\[#{c}\]</a>"}
|
29
|
+
|
30
|
+
luptraces = [uptrace_ids[t.id]].flatten.compact.map{|x| self[x]}
|
31
|
+
|
32
|
+
luptraces=luptraces.
|
33
|
+
sort_by{|x| trace_order_index(x.id)}.
|
34
|
+
map{|u|
|
35
|
+
um = u.id.gsub("_","-")
|
36
|
+
" - <a href=\"#RT-#{um}\">[#{u.id}]</a> #{u.header_orig}"
|
37
|
+
}
|
38
|
+
|
39
|
+
["- ->[#{t.id}] <!-- --> <a id=\"RT-#{tidm}\"/>**#{t.header_orig}**" +
|
40
|
+
# " (#{t.contributes_to.join(', ')})", "",
|
41
|
+
" (#{lContributes.join(', ')})", "",
|
42
|
+
luptraces
|
43
|
+
].flatten.join("\n")
|
44
|
+
}.join("\n\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# this generates the downstream_tracefile
|
49
|
+
def to_downstream_tracefile(selectedCategory)
|
50
|
+
all_traces(selectedCategory).
|
51
|
+
sort_by{|x| trace_order_index(x.id) }.
|
52
|
+
map{|t|
|
53
|
+
"\n\n[#{t.id}] **#{t.header_orig}** { }()"
|
54
|
+
}.join("\n\n")
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
|
59
|
+
# This factory method processes all traces in a particular markdown file
|
60
|
+
# and returns a TraceableSet
|
61
|
+
#
|
62
|
+
|
63
|
+
# @param mdFile [String] name of the markdown File which shall be scanned
|
64
|
+
|
65
|
+
#
|
66
|
+
|
67
|
+
# @return [TraceableSet] The set of traceables found in the markdown file
|
68
|
+
def self.processTracesInMdFile(mdFile)
|
69
|
+
|
70
|
+
parser=TraceInMarkdownParser.new
|
71
|
+
parser.consume_all_input = true
|
72
|
+
|
73
|
+
raw_md_code_file=File.open(mdFile, "r:bom|utf-8")
|
74
|
+
raw_md_code = raw_md_code_file.readlines.join
|
75
|
+
raw_md_code_file.close
|
76
|
+
# print mdFile
|
77
|
+
result = parser.parse(raw_md_code)
|
78
|
+
# print " ... parsed\n" todo: use logger here
|
79
|
+
|
80
|
+
result_set = TraceableSet.new
|
81
|
+
|
82
|
+
if result
|
83
|
+
result.descendant.select{|x| x.getLabel==="trace"}.each{|c|
|
84
|
+
id = c.traceId.payload.text_value
|
85
|
+
uptraces = c.uptraces.payload.text_value
|
86
|
+
header = c.traceHead.payload.text_value
|
87
|
+
bodytext = c.traceBody.payload.text_value
|
88
|
+
uptraces = c.uptraces.payload.text_value
|
89
|
+
# Populate the Traceable entry
|
90
|
+
theTrace = Traceable.new
|
91
|
+
theTrace.info = mdFile
|
92
|
+
theTrace.id = id
|
93
|
+
theTrace.header_orig = header
|
94
|
+
theTrace.body_orig = bodytext
|
95
|
+
theTrace.trace_orig = c.text_value
|
96
|
+
theTrace.contributes_to = uptraces.gsub!(/\s*/, "").split(",")
|
97
|
+
theTrace.category = :SPECIFICATION_ITEM
|
98
|
+
result_set.add(theTrace)
|
99
|
+
}
|
100
|
+
# puts " .... finished"
|
101
|
+
else
|
102
|
+
puts ["","-----------", texFile, parser.failure_reason].join("\n")
|
105
103
|
end
|
104
|
+
result_set
|
105
|
+
end
|
106
|
+
|
106
107
|
|
107
|
-
|
108
|
-
end
|
108
|
+
end
|
@@ -43,6 +43,8 @@ class TraceableSet
|
|
43
43
|
# * second
|
44
44
|
#
|
45
45
|
# @return [type] [description]
|
46
|
+
#
|
47
|
+
#
|
46
48
|
def add(traceable)
|
47
49
|
#TOOD: check traceable
|
48
50
|
#TODO: check if append can be optimized
|
@@ -284,7 +286,7 @@ class TraceableSet
|
|
284
286
|
# @param [Nokogiri::XML::Document] doc - the document
|
285
287
|
# @return [Nokogiri::XML::Document] the beautified document
|
286
288
|
def xp(doc)
|
287
|
-
xsl
|
289
|
+
xsl =<<-XSL
|
288
290
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
289
291
|
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
|
290
292
|
<xsl:strip-space elements="*"/>
|
@@ -292,7 +294,7 @@ class TraceableSet
|
|
292
294
|
<xsl:copy-of select="."/>
|
293
295
|
</xsl:template>
|
294
296
|
</xsl:stylesheet>
|
295
|
-
XSL
|
297
|
+
XSL
|
296
298
|
|
297
299
|
|
298
300
|
xslt = Nokogiri::XSLT(xsl)
|
@@ -17,6 +17,8 @@ require 'tmpdir'
|
|
17
17
|
require 'nokogiri'
|
18
18
|
require "rubyXL"
|
19
19
|
require 'logger'
|
20
|
+
require 'wortsammler/latex_helper'
|
21
|
+
|
20
22
|
|
21
23
|
Encoding.default_external = Encoding::UTF_8
|
22
24
|
Encoding.default_internal = Encoding::UTF_8
|
@@ -822,13 +824,14 @@ class PandocBeautifier
|
|
822
824
|
tempfile = input
|
823
825
|
tempfilePdf = "#{@tempdir}/x.TeX.md".to_osPath
|
824
826
|
tempfileHtml = "#{@tempdir}/x.html.md".to_osPath
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
827
|
+
outfile = "#{outdir}/#{outname}".to_osPath
|
828
|
+
outfilePdf = "#{outfile}.pdf"
|
829
|
+
outfileDocx = "#{outfile}.docx"
|
830
|
+
outfileHtml = "#{outfile}.html"
|
831
|
+
outfileRtf = "#{outfile}.rtf"
|
832
|
+
outfileLatex = "#{outfile}.latex"
|
833
|
+
outfileText = "#{outfile}.txt"
|
834
|
+
outfileSlide = "#{outfile}.slide.html"
|
832
835
|
|
833
836
|
if vars.has_key? :frontmatter
|
834
837
|
latexTitleInclude = "--include-before-body=#{vars[:frontmatter].esc}"
|
@@ -871,7 +874,6 @@ class PandocBeautifier
|
|
871
874
|
|
872
875
|
begin
|
873
876
|
|
874
|
-
|
875
877
|
if format.include?("frontmatter") then
|
876
878
|
|
877
879
|
ReferenceTweaker.new("pdf").prepareFile(tempfile, tempfilePdf)
|
@@ -880,15 +882,8 @@ class PandocBeautifier
|
|
880
882
|
`#{cmd}`
|
881
883
|
end
|
882
884
|
|
883
|
-
if format.include?("pdf") then
|
884
|
-
@log.debug("creating #{outfilePdf}")
|
885
|
-
ReferenceTweaker.new("pdf").prepareFile(tempfile, tempfilePdf)
|
886
|
-
cmd="pandoc -S #{tempfilePdf.esc} #{toc} --standalone #{option_chapters} --latex-engine xelatex --number-sections #{vars_string}" +
|
887
|
-
" --template #{latexStyleFile.esc} --ascii -o #{outfilePdf.esc} #{latexTitleInclude}"
|
888
|
-
`#{cmd}`
|
889
|
-
end
|
890
885
|
|
891
|
-
if format.include?("latex") then
|
886
|
+
if (format.include?("pdf") | format.include?("latex")) then
|
892
887
|
@log.debug("creating #{outfileLatex}")
|
893
888
|
ReferenceTweaker.new("pdf").prepareFile(tempfile, tempfilePdf)
|
894
889
|
|
@@ -897,6 +892,32 @@ class PandocBeautifier
|
|
897
892
|
`#{cmd}`
|
898
893
|
end
|
899
894
|
|
895
|
+
|
896
|
+
if format.include?("pdf") then
|
897
|
+
@log.debug("creating #{outfilePdf}")
|
898
|
+
ReferenceTweaker.new("pdf").prepareFile(tempfile, tempfilePdf)
|
899
|
+
#cmd="pandoc -S #{tempfilePdf.esc} #{toc} --standalone #{option_chapters} --latex-engine xelatex --number-sections #{vars_string}" +
|
900
|
+
# " --template #{latexStyleFile.esc} --ascii -o #{outfilePdf.esc} #{latexTitleInclude}"
|
901
|
+
cmd="xelatex -halt-on-error -interaction nonstopmode -output-directory=#{outdir.esc} #{outfileLatex.esc}"
|
902
|
+
#cmdmkindex = "makeindex \"#{outfile.esc}.idx\""
|
903
|
+
|
904
|
+
latex=LatexHelper.new.set_latex_command(cmd).setlogger(@log)
|
905
|
+
latex.run(outfileLatex)
|
906
|
+
|
907
|
+
messages=latex.log_analyze("#{outdir}/#{outname}.log")
|
908
|
+
|
909
|
+
removeables = ["toc", "aux", "bak", "idx", "ilg", "ind" ]
|
910
|
+
removeables << "log" unless messages > 0
|
911
|
+
|
912
|
+
|
913
|
+
removeables << "latex" unless format.include?("latex")
|
914
|
+
removeables = removeables.map{|e| "#{outdir}/#{outname}.#{e}"}.select{|f| File.exists?(f)}
|
915
|
+
removeables.each{|e|
|
916
|
+
@log.debug "removing file: #{e}"
|
917
|
+
FileUtils.rm e
|
918
|
+
}
|
919
|
+
end
|
920
|
+
|
900
921
|
if format.include?("html") then
|
901
922
|
#todo: handle css
|
902
923
|
@log.debug("creating #{outfileHtml}")
|
@@ -951,7 +972,8 @@ class PandocBeautifier
|
|
951
972
|
`#{cmd}`
|
952
973
|
end
|
953
974
|
rescue Exception => e
|
954
|
-
@log.error "failed to perform #{cmd}, #{e.message}"
|
975
|
+
@log.error "failed to perform #{cmd}, \n#{e.message}"
|
976
|
+
@log.error e.backtrace.join("\n")
|
955
977
|
#TODO make a try catch block kere
|
956
978
|
end
|
957
979
|
nil
|
@@ -46,11 +46,12 @@ optparse = OptionParser.new do|opts|
|
|
46
46
|
opts.on( "-v", '--version', 'print Version info, then turn on verbose mode' ) do
|
47
47
|
options[:version] = true
|
48
48
|
options[:verbose] = true
|
49
|
+
$log.level=Logger::DEBUG
|
49
50
|
end
|
50
51
|
|
51
52
|
opts.separator nil
|
52
53
|
|
53
|
-
options[:init] =
|
54
|
+
options[:init] = nil
|
54
55
|
opts.on( "-n", '--init DIR', 'create a project folder in DIR' ) do|file|
|
55
56
|
options[:init] = file
|
56
57
|
end
|
@@ -58,12 +59,12 @@ optparse = OptionParser.new do|opts|
|
|
58
59
|
|
59
60
|
opts.separator nil
|
60
61
|
|
61
|
-
options[:inputpath] =
|
62
|
+
options[:inputpath] = nil
|
62
63
|
opts.on( '-i', '--inputpath PATH', 'set input file/project folder for processing') do|path|
|
63
64
|
options[:inputpath] = path
|
64
65
|
end
|
65
66
|
|
66
|
-
options[:manifest] =
|
67
|
+
options[:manifest] = nil
|
67
68
|
opts.on( '-m', '--manifest PATH', 'set mainfest file for processing' ) do|file|
|
68
69
|
options[:manifest] = file
|
69
70
|
end
|
@@ -75,7 +76,7 @@ optparse = OptionParser.new do|opts|
|
|
75
76
|
options[:outputformats] = formatlist
|
76
77
|
end
|
77
78
|
|
78
|
-
options[:outputfolder] =
|
79
|
+
options[:outputfolder] = nil
|
79
80
|
opts.on( '-o', '--outputfolder PATH', 'set the output to PATH' ) do|path|
|
80
81
|
options[:outputfolder] = path
|
81
82
|
end
|
@@ -120,6 +121,5 @@ rescue RegexpError => error
|
|
120
121
|
exit
|
121
122
|
end
|
122
123
|
|
123
|
-
|
124
124
|
Wortsammler.verify_options(options)
|
125
125
|
Wortsammler.execute(options)
|
@@ -0,0 +1,244 @@
|
|
1
|
+
# a=LatexHelper.new.set_command(cmd).setlogger(log).
|
2
|
+
|
3
|
+
class LatexHelper
|
4
|
+
|
5
|
+
attr_accessor :latex_result, :mkindex_result
|
6
|
+
|
7
|
+
@latex_command = nil
|
8
|
+
@latex_result=nil
|
9
|
+
@mkindex_result=nil
|
10
|
+
@log=nil
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
#
|
15
|
+
# [initialize description]
|
16
|
+
#
|
17
|
+
# @return [type] [description]
|
18
|
+
def initialize()
|
19
|
+
end
|
20
|
+
|
21
|
+
def setlogger(log)
|
22
|
+
@log=log
|
23
|
+
return self
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
#
|
29
|
+
# [set_latex_command description]
|
30
|
+
# @param cmd [type] [description]
|
31
|
+
#
|
32
|
+
# @return [type] [description]
|
33
|
+
def set_latex_command(cmd)
|
34
|
+
@latex_command=cmd
|
35
|
+
return self
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
#
|
40
|
+
# [run_latex description]
|
41
|
+
#
|
42
|
+
# @return [type] [description]
|
43
|
+
def run_latex()
|
44
|
+
@latex_result = `#{@latex_command}`
|
45
|
+
return self
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# [run_mkindex description]
|
50
|
+
# @param outfile [type] [description]
|
51
|
+
#
|
52
|
+
# @return [type] [description]
|
53
|
+
def run_mkindex(outfile)
|
54
|
+
outfilename=File.basename(outfile, ".*")
|
55
|
+
indexinfile="#{outfilename}.idx"
|
56
|
+
indexlogfile="#{outfilename}.ilg"
|
57
|
+
indexoutfile="#{outfilename}.ind"
|
58
|
+
|
59
|
+
current_dir = FileUtils.pwd
|
60
|
+
FileUtils.cd(File.dirname(outfile)) do |mydir|
|
61
|
+
@mkindex_result=nil
|
62
|
+
if File.exist?(indexinfile) then
|
63
|
+
a=`makeindex -q #{indexinfile.esc} 2>&1`
|
64
|
+
@mkindex_result=ilg_analyse(indexlogfile)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
return self
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
#
|
73
|
+
# [add_sort_key description]
|
74
|
+
# @param indexinfile [type] [description]
|
75
|
+
#
|
76
|
+
# @return [type] [description]
|
77
|
+
def add_sort_key(indexinfile)
|
78
|
+
content=File.open(indexinfile, "r").read
|
79
|
+
content.gsub!(/\\indexentry{([^\}]*)}/){|entry|
|
80
|
+
reference=$1.split("|").first
|
81
|
+
originalterms=reference.split("!")
|
82
|
+
newterms=originalterms.map{|ot|
|
83
|
+
|
84
|
+
sortterm=ot.clone
|
85
|
+
sortterm.gsub!('Ä', "ae")
|
86
|
+
sortterm.gsub!('ä', "ae")
|
87
|
+
sortterm.gsub!('Ö', "oe")
|
88
|
+
sortterm.gsub!('ö', "oe")
|
89
|
+
sortterm.gsub!('Ü', "ue")
|
90
|
+
sortterm.gsub!('ü', "ue")
|
91
|
+
sortterm.gsub!('ß', "ss")
|
92
|
+
nt=ot
|
93
|
+
nt="#{sortterm}@#{ot}" unless sortterm.include?("@")
|
94
|
+
}.join("!")
|
95
|
+
# require 'pry';binding.pry
|
96
|
+
|
97
|
+
entry.gsub(reference, newterms)
|
98
|
+
}
|
99
|
+
|
100
|
+
File.open(indexinfile, "w") do |f|
|
101
|
+
f.puts(content)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# [run description]
|
107
|
+
# @param outfile [type] [description]
|
108
|
+
#
|
109
|
+
# @return [type] [description]
|
110
|
+
def run(outfile)
|
111
|
+
|
112
|
+
reruncount=3
|
113
|
+
|
114
|
+
run_latex()
|
115
|
+
run_mkindex(outfile)
|
116
|
+
|
117
|
+
while need_rerun? && ((reruncount-=1) >0)
|
118
|
+
run_latex()
|
119
|
+
run_mkindex(outfile)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
#
|
125
|
+
# [need_rerun? description]
|
126
|
+
#
|
127
|
+
# @return [type] [description]
|
128
|
+
def need_rerun?()
|
129
|
+
@latex_result.include?("Rerun to get")
|
130
|
+
true
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
#
|
135
|
+
# [ilg_analyse description]
|
136
|
+
# @param logfilename [type] [description]
|
137
|
+
#
|
138
|
+
# @return [type] [description]
|
139
|
+
def ilg_analyse(logfilename)
|
140
|
+
stat = {}
|
141
|
+
error = nil
|
142
|
+
File.readlines(logfilename).each{ |logline|
|
143
|
+
if error #Index error announced in previous line
|
144
|
+
( stat[:errors] ||= [] ) << "#{logline.chomp.sub(/.*--/, "")} #{error}"
|
145
|
+
error = nil
|
146
|
+
else
|
147
|
+
case logline
|
148
|
+
when /Scanning input file (.*)\...done \((.*) entries accepted, (.*) rejected\)./
|
149
|
+
#~ stat[:source_information] ||= [] << "input file #{$1} (#{$2} entries accepted, #{$3} rejected)"
|
150
|
+
stat[:source_information] ||= []
|
151
|
+
stat[:source_information] << "Input file: #{$1}"
|
152
|
+
stat[:source_information] << "Entries accepted: #{$2}"
|
153
|
+
stat[:source_information] << "Entries rejected: #{$3}"
|
154
|
+
#~ when /done \((.*) entries accepted, (.*) rejected\)./
|
155
|
+
#~ result[:rejected] += $2.to_i() if $2.to_i() > 0
|
156
|
+
when /!! Input index error \(file = (.*), line = (.*)\):/
|
157
|
+
#Error-message on next line
|
158
|
+
error = "(file #{$1} line #{$2}: #{logline})"
|
159
|
+
end
|
160
|
+
end #if error
|
161
|
+
}
|
162
|
+
stat
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
#
|
167
|
+
# This analyzes the latex log file thereby filters warenings and errors
|
168
|
+
# @param logfilename [String] The filename of the log
|
169
|
+
#
|
170
|
+
# @return [Nil] no return
|
171
|
+
def log_analyze(logfilename)
|
172
|
+
result = {
|
173
|
+
errors: 0,
|
174
|
+
warings: 0,
|
175
|
+
loglines: []
|
176
|
+
}
|
177
|
+
|
178
|
+
outCounter = 0
|
179
|
+
lineCounter = 0
|
180
|
+
errorCounter = 0
|
181
|
+
warningCounter = 0
|
182
|
+
previousLine = ""
|
183
|
+
|
184
|
+
logfilename_reported = File.basename(logfilename)
|
185
|
+
|
186
|
+
File.readlines(logfilename).each{ |l|
|
187
|
+
logline = l.strip
|
188
|
+
lineCounter += 1
|
189
|
+
|
190
|
+
|
191
|
+
if logline =~ /Output written on/ then
|
192
|
+
outCounter = 5
|
193
|
+
end
|
194
|
+
|
195
|
+
if logline =~ /Running / then
|
196
|
+
lineCounter = 0
|
197
|
+
end
|
198
|
+
|
199
|
+
if logline =~ /Buffer size exceeded/ then
|
200
|
+
lineCounter = 0
|
201
|
+
@log.error ("\n!Error Buffer size exceeded, for details see line #{lineCounter} #{logfilename_reported}")
|
202
|
+
@log.info previousLine
|
203
|
+
errorCounter += 1
|
204
|
+
outCounter=5
|
205
|
+
end
|
206
|
+
|
207
|
+
if logline =~ /^!/ then
|
208
|
+
lineCounter = 0
|
209
|
+
@log.error ("LaTeX error; for details see line #{lineCounter} #{logfilename_reported}")
|
210
|
+
errorCounter += 1
|
211
|
+
outCounter=5
|
212
|
+
end
|
213
|
+
|
214
|
+
if logline =~ /\[ INFO\]/ then
|
215
|
+
$log.info logline
|
216
|
+
end
|
217
|
+
|
218
|
+
if logline =~ /Warning:|pdfTeX warning/ then
|
219
|
+
$log.warn "for details see line #{lineCounter} #{logfilename_reported}"
|
220
|
+
warningCounter += 1
|
221
|
+
outCounter = 5
|
222
|
+
end
|
223
|
+
|
224
|
+
if logline =~ /^(Underfull|Overfull)/ then
|
225
|
+
outCounter = 0
|
226
|
+
end
|
227
|
+
|
228
|
+
if (outCounter > 0) then
|
229
|
+
$log.info logline
|
230
|
+
outCounter -= 1
|
231
|
+
|
232
|
+
if outCounter == 0 then
|
233
|
+
$log.info ""
|
234
|
+
end
|
235
|
+
end
|
236
|
+
}
|
237
|
+
|
238
|
+
@log.info ("logfilter: errors = #{errorCounter}")
|
239
|
+
@log.info ("logfilter: warnings = #{warningCounter}")
|
240
|
+
|
241
|
+
errorCounter + warningCounter
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
data/lib/wortsammler/version.rb
CHANGED