Class: RunTeX::Makeindex

Inherits:
Tool
  • Object
show all
Defined in:
lib/runtex_makeindex.rb

Overview

  • glossaries.sty

Constant Summary

Constants included from Catch_output

Catch_output::STDERR_ORIG, Catch_output::STDOUT_ORIG

Instance Attribute Summary

Attributes inherited from Tool

#options, #step

Instance Method Summary collapse

Methods inherited from Tool

#build_cmd, #summary

Methods included from Catch_output

#catch_screen_output, #catch_stderr, #catch_stdout

Constructor Details

#initialize(job, options = {}) ⇒ Makeindex

Returns a new instance of Makeindex.


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/runtex_makeindex.rb', line 12

def initialize(job, options = {})
  super(job, options,
      :file_in => "#{job.basename}.idx",
      :file_out => "#{job.basename}.ind",
      :file_log => "#{job.basename}.ilg"
    )
  @options.keys.each{|key|
    case key
      when :file_in   # normally idx

      when :file_out # normally ind

      when :file_log # normally ilg

      when :format
      when :name
      else
        @job.log.error( "#{self.class}: Unknown option #{key}" ) if @job.log.error?
    end
  }
end

Instance Method Details

#analyse_log(logdata) ⇒ Object

Analyse the makeindex-log


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/runtex_makeindex.rb', line 81

def analyse_log( logdata )
  @job.log.debug( "#{@step} Analyse log-file") if @job.log.debug?
  result = {  
          :error    => [],
          #~ :warning => [],

          :info => [],
          :rejected => 0,
      }
  error = nil
  logdata.each{ |logline|
    if error  #Index error

      result[:error] << "#{logline.chomp.sub(/.*--/, "")} #{error}"
      error = nil
    else
      case logline
      when /Scanning input file (.*)\...done \((.*) entries accepted, (.*) rejected\)./
        result[:info] << "input file #{$1} (#{$2} entries accepted, #{$3} rejected)"
      when /done \((.*) entries accepted, (.*) rejected\)./
        result[:rejected] += $2.to_i() if $2.to_i() > 0
      when /!! Input index error \(file = (.*), line = (.*)\):/
        #Error-message on next line

        error = "(file #{$1} line #{$2}: #{logline})"
      end #case logline

    end #if error

  }
  result[:error] << "#{logline.chomp.sub(/.*--/, "")} #{error}" if error
  return result
end

#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

#inspectObject

Used in logger


110
111
112
# File 'lib/runtex_makeindex.rb', line 110

def inspect()
  "Makeindex<#{@options[:name]}>"
end