Class: RunTeX::Tool
Overview
A tool may require other tools (LaTeX need BibTeX, Makeindex…)
Direct Known Subclasses
Constant Summary
Constants included from Catch_output
Catch_output::STDERR_ORIG, Catch_output::STDOUT_ORIG
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Read options.
-
#step ⇒ Object
readonly
Actual step.
Instance Method Summary collapse
-
#build_cmd(configurationkey, par_values = @options) ⇒ Object
Build the command.
-
#execute(step) ⇒ Object
Call the tool.
-
#initialize(job, options, defaults) ⇒ Tool
constructor
Defines some general attributes and set the options.
-
#summary(option = :list) ⇒ Object
A summary of the last Tool#execute.
Methods included from Catch_output
#catch_screen_output, #catch_stderr, #catch_stdout
Constructor Details
#initialize(job, options, defaults) ⇒ Tool
Defines some general attributes and set the options.
The redefined method code has only two parameters, the default is set un the super-call.
26 27 28 29 30 31 32 |
# File 'lib/runtex_tool.rb', line 26 def initialize( job, , defaults ) = defaults.merge() @job = job @step = "%02i " % @job.texrun unless @step #~ @job.log.debug( "#{@step} Create #{self} (#{@options.inspect})" ) if @job.log.debug? @result = {} #Result of the last execution end |
Instance Attribute Details
#options ⇒ Object (readonly)
Read options
36 37 38 |
# File 'lib/runtex_tool.rb', line 36 def end |
#step ⇒ Object (readonly)
Actual step
34 35 36 |
# File 'lib/runtex_tool.rb', line 34 def step @step end |
Instance Method Details
#build_cmd(configurationkey, par_values = @options) ⇒ Object
Build the command.
Bases is the configuration.
The key ‘call’ defines the programm.
‘parameters’ contains a list of all parameters for the call. Each parameter contains at least two values: a flag and a content.
The content may be a string or a symbol. If it is a symbol, the value must be a key in the hash ‘par_values’. (Exception: option :optional)
After the two main parameters (which can be ‘nil’), options can be used: -:no_space_sep between the flag and the value is no space.
Example: latex -interaction=batchmode instead latex -interaction= batchmode
-:optional the parameter is suppressed if the value is empty.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/runtex_tool.rb', line 87 def build_cmd( configurationkey, par_values = ) configuration = Job_chain::Configuration[configurationkey] par_list = [] configuration['parameters'].each{|flag, key, *| next if .include?(:optional) and ! par_values[key] #~ puts flag.inspect #~ puts options.inspect parameter = '' parameter << flag if flag and flag != 'nil' parameter << ' ' unless .include?(:no_space_sep) case key when Symbol parameter << par_values[key] if par_values[key] if ! .include?(:optional) and ! par_values[key] @job.log.error( "Parameter #{key.inspect} (#{flag}) missing to execute #{configurationkey}") if @job.log.error? next end when String #a constand parameter << key end par_list << parameter } #~ puts par_list.inspect cmd = "#{configuration['call']} #{par_list.join(' ')}" end |
#execute(step) ⇒ Object
Call the tool. Result is a hash with:
-
errors
-
warnings
-
messages
120 121 122 123 124 125 |
# File 'lib/runtex_tool.rb', line 120 def execute( step ) #~ raise "Method execute not redefined for #{self.class}" @step = "%02i-%02i" % [ @job.texrun, step ] @job.log.info( "#{@step} Call #{self.inspect}" ) if @job.log.info? @summary = 'No summary available' end |
#summary(option = :list) ⇒ Object
A summary of the last Tool#execute
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/runtex_tool.rb', line 38 def summary( option = :list) return 'No summary available' if @result.empty? (@result.keys - [:error, :warning, :info, :rejected]).each{|key| @job.log.fatal("RunTeX::Tool#summary: Unknown key #{key.inspect}") if @job.log.fatal? puts self.inspect puts @result.inspect puts @result.to_yaml } @job.log.fatal("RunTeX::Tool#summary: Unknown option #{option.inspect}") if @job.log.fatal? and ! [:list, :count].include?(option) summary = '' [ [:error, 'Errors'], [:warning,'Warnings'], [:rejected,'Rejected entries'], #makeindex, should correspond with errors [:info,'Information'], ].each{|key, text| next unless @result[key] next if @result[key].respond_to?(:empty?) and @result[key].empty? case option when :list summary << "#{text}:\n" summary << @result[key].to_yaml.sub(/--- \n/, '') when :count summary << "#{text}: #{@result[key].size}; " end } return summary end |