Class: RunTeX::BibTeX

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

Overview

Instead gloss.sty I recommend glossaries.sty (uses makeindex/xindy).

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 = {}) ⇒ BibTeX

Returns a new instance of BibTeX.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/runtex_bibtex.rb', line 13

def initialize(job, options = {})
  super(job, options, 
        :source => "#{job.basename}.aux",
        :target => "#{job.basename}.bbl",
        :log => "#{job.basename}.blg"
      )
  @options.keys.each{|key|
    case key
      when :source
        if @options[:source] !~ /\.aux/
          @job.log.error( "#{@step} #{self.class}: Source is no aux-file (#{@options[:source]})" ) if @job.log.error?
        end
      when :target
        if @options[:target] !~ /\.bbl/
          @job.log.error( "#{@step} #{self.class}: Target is no bbl-file (#{@options[:target]})" ) if @job.log.error?
        end
      when :log
        if @options[:log] !~ /\.blg/
          @job.log.error( "#{@step} #{self.class}: Log is no blg-file (#{@options[:log]})" ) if @job.log.error?
        end
      else
        @job.log.error( "#{@step} #{self.class}: Unknown option #{key}" ) if @job.log.error?
    end
  }
end

Instance Method Details

#execute(step) ⇒ Object

Take the aux-file (source) and create the bbl-file.



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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/runtex_bibtex.rb', line 39

def execute( step )
  super(step)
  @result = { 
          :error    => [],
          :warning  => [],
          :info => [],
      }
  #~ Logger.add( 5, self.class, "Execute #{Configuration.bibtex}for \"#{@filename}\"" )

  if File.exist?( @options[:source])
    @job.add2zip( @options[:source] )
  end
  if File.exist?( @options[:target])
    @job.add2zip( @options[:target] )
    bblold = File.readlines(@options[:target])
  end
  
  subrc = nil
  cmd = build_cmd('bibtex', @options)
  @job.log.debug( "#{@step} Call #{cmd}") if @job.log.debug?
  stdout, stderr = catch_screen_output{    subrc = system( cmd ) }
  #~ Logger.add_file( @filename + '.blg' ) if @logInclude

  if ! subrc
    @job.log.error( "#{@step} Error executing #{cmd}")
  end
  if File.exist?( @options[:target])
    @job.add2zip( @options[:target] )
    bblnew = File.readlines(@options[:target])
  else
    @job.log.error( "#{@step} No result after executing #{cmd}")
  end
  if bblold != bblnew
    @job.please_rerun('Bibliography changed')
  end
 
  @job.helpfiles << @options[:source]
  @job.helpfiles << @options[:target]
  @job.helpfiles << "#{@job.basename}-blx.bib"  #This is an auxiliary file used by the 'biblatex' package.

  @job.logfiles << @options[:log]
  
  
  if File.exist?( @options[:log])
    @job.add2zip( @options[:log] )
    File.readlines(@options[:log]).each{ |logline|
      case logline
        when /Database file #(.*): (.*)/
          @result[:info] << "Database file #{$2} used"
        when  /Warning--I didn't find a database entry for "(.*)"/
          @result[:warning] << "Databaseentry #{$1} missing"
        #~ when  /Warning--Empty definition in (.*)/

          #~ result[:warning] << "Empty definition #{$1}"

        when  /Warning--(.*)/
          @result[:warning] << "#{$1}"
        when  /I couldn't open (.*) file (.*)/
          @result[:error] << "#{$1} #{$2} not found"
        when  /I found no (.*) commands---while reading file(.*)/
          @result[:warning] << "found no #{$1} in #{$2}"      
        when  /(.*)---line (.*) of file(.*)/
          #line-number ist unsinnig

          @result[:error] << "#{$1} in #{$3}"
      end
    }
  else
    @job.log.error( "#{@step} No BibTeX-Log found #{@options[:log]}")
  end
  return @result
end

#inspectObject

Used in logger



106
107
108
# File 'lib/runtex_bibtex.rb', line 106

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