class Rake4LaTeX::Splitindex
Checks for a given idx-file if splitindx is used.
Attributes
indices[R]
List of all indices
targets[R]
List of all targets and there content
Public Class Methods
new( idx_basename, logger )
click to toggle source
# File lib/rake4latex/splitindex.rb, line 7 def initialize( idx_basename, logger ) @basename = idx_basename @logger = logger if ! File.exist?( @basename ) @logger.error("Error: No idx-file for splitindex (#{@basename})") @indices = ['idx'] return end @targets = {} #Example: #~ \indexentry[Fields]{MANDT!MARA|hyperpage}{4} #~ \indexentry[DataElement]{MANDT!MARA-MANDT|hyperpage}{4} File.readlines(@basename).each{|idx_line| case idx_line when /\indexentry\[(.+?)\]\{(.+?)\}\{(.+?)\}/ (@targets[$1] ||= []) << "\\indexentry{#{$2}}{#{$3}}" when /\indexentry\{(.+?)\}\{(.+?)\}/ (@targets['idx'] ||= []) << "\\indexentry{#{$1}}{#{$2}}" else @logger.warn("Unknown indexentry-type for splitindex (#{idx_line.split})") end } #File.readlines(@basename) @indices = ( @targets.keys << 'idx' ).uniq end
Public Instance Methods
call_makeindex( idxname )
click to toggle source
Call makeindex for the given idx-file
# File lib/rake4latex/splitindex.rb, line 64 def call_makeindex( idxname ) cmd = Rake4LaTeX.build_cmd( 'makeindex', :file_in => idxname ) stdin, stdout, stderr, wait_thr = Open3.popen3(cmd) if wait_thr.value.exitstatus != 0 @logger.fatal("There where Makeindex errors for #{idxname}\n#{stderr.readlines.join}") end end
execute()
click to toggle source
Actions:
-
Build the splitted idx-files
-
add the help files to CLEAN
-
call makeindex for each file
# File lib/rake4latex/splitindex.rb, line 46 def execute() @logger.error("Splitindex#execute for normal index") if makeindex? and @logger.info? @logger.info("Build splitindex-files for #{@targets.keys.inspect}") if @logger.info? @targets.each{|target, content| idxname = @basename.sub(/\.idx$/, "-#{target}.idx") @logger.debug("Build Split-index #{target} (#{idxname})") File.open(idxname, 'w'){| idx | idx << content.join("\n") } CLEAN << idxname CLEAN << idxname.ext('ind') CLEAN << idxname.ext('ilg') call_makeindex( idxname ) } #@targets.each end
makeindex?()
click to toggle source
Flag if it is no splitindex, but a “normal” index for makeindex.
# File lib/rake4latex/splitindex.rb, line 39 def makeindex?() @indices.size == 1 #idx always added end