Method: RunTeX::Makeindex#execute

Defined in:
lib/runtex_makeindex.rb

#execute(step) ⇒ Object

Start makeindex



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
72
73
74
75
76
77
78
# File 'lib/runtex_makeindex.rb', line 31

def execute( step )
  super(step)
  @result = {	
          :error		=> [],
          :info	=> [],
      }
  
  #Get existing index-data first
  if File.exist?( @options[:file_out] )
    @job.add2zip( @options[:file_out] )
    ind_old = File.readlines( @options[:file_out] )
  end
  
  #Build the call for makeindex
  cmd = build_cmd('makeindex')
  #~ cmd = build_cmd('makeindex', @options) )
  @job.log.debug( "#{@step} Start Makeindex: #{cmd}") if @job.log.debug?
  STDOUT.flush
  
  #Execute makeindex
  subrc = nil
  stdout, stderr = catch_screen_output{ subrc = system(cmd) }
  @job.log.error( "#{@step} Error Makeindex: #{cmd}") if !subrc and @job.log.error?

  if File.exist?( @options[:file_out] )
    @job.add2zip( @options[:file_out] )
    ind_new = File.readlines( @options[:file_out] )
  end

  @job.logfiles   << @options[:file_log]
  @job.helpfiles  << @options[:file_in]
  @job.helpfiles  << @options[:file_out]


  if ind_old != ind_new
    @job.please_rerun("Index #{@options[:file_out]} changed")
  end

  if File.exist?( @options[:file_log] )
    @job.add2zip( @options[:file_log] )
    @result = analyse_log( File.readlines( @options[:file_log] ) )
  else
    @job.log.error( "#{@step} Error Makeindex: No log #{@options[:file_log]}") if @job.log.error?
    @result[:error] << "Error Makeindex: No log #{@options[:file_log]}"
  end

  return @result
end