Class: RunTeX::Splitindex
Overview
Splitindex - Define multiple indices by splitting the main index.
Constant Summary
Constants included from Catch_output
Catch_output::STDERR_ORIG, Catch_output::STDOUT_ORIG
Instance Attribute Summary
Attributes inherited from Tool
Instance Method Summary collapse
-
#execute(step) ⇒ Object
Split the index into the sub-Indices.
-
#initialize(job, options = {}) ⇒ Splitindex
constructor
A new instance of Splitindex.
-
#inspect ⇒ Object
Used in logger.
Methods inherited from Tool
Methods included from Catch_output
#catch_screen_output, #catch_stderr, #catch_stdout
Constructor Details
#initialize(job, options = {}) ⇒ Splitindex
Returns a new instance of Splitindex.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/runtex_splitindex.rb', line 9 def initialize(job, = {}) super(job, , {}) #fixme obligatory parameter .keys.each{|key| case key when :source else @job.log.error( "#{@step} #{self.class}: Unknown option #{key}" ) if @job.log.error? end } end |
Instance Method Details
#execute(step) ⇒ Object
Split the index into the sub-Indices
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 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 69 70 71 |
# File 'lib/runtex_splitindex.rb', line 21 def execute( step ) super(step) @job.log.debug( "#{@step} Split index into sub indices (#{self.class})" ) if @job.log.debug? @result = { :error => [], :info => [], } #Get existing index-data first if File.exist?( [:source] ) @job.add2zip( [:source] ) else Logger.add( 1, self.class, "No idx-file for splitindex (#{@source})") @result[:error] << "Error: No idx-file for splitindex (#{@options[:source]})" end targets = {} #Example: #~ \indexentry[Fields]{MANDT!MARA|hyperpage}{4} #~ \indexentry[DataElement]{MANDT!MARA-MANDT|hyperpage}{4} File.readlines([:source]).each{|idx_line| case idx_line when /\indexentry\[(.+?)\]\{(.+?)\}\{(.+?)\}/ targets[$1] = [] unless targets[$1] targets[$1] << "\\indexentry{#{$2}}{#{$3}}" when /\indexentry\{(.+?)\}\{(.+?)\}/ targets['idx'] = [] unless targets['idx'] targets['idx'] << "\\indexentry{#{$1}}{#{$2}}" end } @job.helpfiles << [:source] targets.each{|target, content| @job.log.debug( "#{@step} Build Split-index #{target}" ) if @job.log.debug? @result[:info] << "Build Split-index #{target}" File.open("#{@job.basename}-#{target}.idx", 'w'){| idx | idx << content.join("\n") } #Call makeindex for each element @job << Makeindex.new( @job, :name => "Sub-Index #{target}", :file_in => "#{@job.basename}-#{target}.idx", :file_out => "#{@job.basename}-#{target}.ind", :file_log => "#{@job.basename}-#{target}.ilg" #~ :format => glossaries_format ) } return @result end |
#inspect ⇒ Object
Used in logger
73 74 75 |
# File 'lib/runtex_splitindex.rb', line 73 def inspect() "SplitIndex<>" end |