Class: Rake::LatexTask

Inherits:
TaskLib
  • Object
show all
Defined in:
lib/rake-latex/latex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) {|_self| ... } ⇒ LatexTask

Returns a new instance of LatexTask.

Yields:

  • (_self)

Yield Parameters:



68
69
70
71
72
# File 'lib/rake-latex/latex.rb', line 68

def initialize(name)
  init(name)
  yield self if block_given?
  define unless name.nil?
end

Instance Attribute Details

#dviObject

Returns the value of attribute dvi.



64
65
66
# File 'lib/rake-latex/latex.rb', line 64

def dvi
  @dvi
end

#figuresObject

Returns the value of attribute figures.



59
60
61
# File 'lib/rake-latex/latex.rb', line 59

def figures
  @figures
end

#include_dirsObject

Returns the value of attribute include_dirs.



62
63
64
# File 'lib/rake-latex/latex.rb', line 62

def include_dirs
  @include_dirs
end

#includesObject

Returns the value of attribute includes.



61
62
63
# File 'lib/rake-latex/latex.rb', line 61

def includes
  @includes
end

#nameObject

Returns the value of attribute name.



57
58
59
# File 'lib/rake-latex/latex.rb', line 57

def name
  @name
end

#need_auxObject

Returns the value of attribute need_aux.



58
59
60
# File 'lib/rake-latex/latex.rb', line 58

def need_aux
  @need_aux
end

#pdfObject

Returns the value of attribute pdf.



66
67
68
# File 'lib/rake-latex/latex.rb', line 66

def pdf
  @pdf
end

#psObject

Returns the value of attribute ps.



65
66
67
# File 'lib/rake-latex/latex.rb', line 65

def ps
  @ps
end

#referencesObject

Returns the value of attribute references.



60
61
62
# File 'lib/rake-latex/latex.rb', line 60

def references
  @references
end

#texObject

Returns the value of attribute tex.



63
64
65
# File 'lib/rake-latex/latex.rb', line 63

def tex
  @tex
end

Instance Method Details

#defineObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/rake-latex/latex.rb', line 92

def define
  @includes.collect!     { |f| Rake.rootdir + f }
  @references.collect!   { |f| Rake.rootdir + f }
  @include_dirs.collect! { |f| File.expand_path(Rake.rootdir + f) }

  @epsfigs = @figures.collect { |f| f.ext('.eps') }
  @pdffigs = @figures.collect { |f| f.ext('.pdf') }

  file @dvi => [@tex] + @references + @epsfigs + @includes do
    |task|

    if not @references.empty? then
      self.run_latex(task, true)
      self.run_bibtex(task)
    end

    self.run_latex(task)
  end

  file @ps => [@dvi] do
    |task|
    run_dvips(task)
  end

  file @pdf => [@tex] + @references + @pdffigs + @includes do
    |task|

    if not @references.empty? then
      self.run_pdflatex(task, true)
      self.run_bibtex(task)
    end

    self.run_pdflatex(task)
  end

  task :dvi => @dvi
  task :ps => @ps
  task :pdf => @pdf

  task :clean do
    rm_f @dvi
    rm_f @ps
    rm_f @pdf
    rm_f @tex.ext("aux")
    rm_f @tex.ext("log")
    rm_f @tex.ext("toc")

    unless @references.empty? then
      rm_f @tex.ext("bbl")
      rm_f @tex.ext("blg")
    end
  end
end

#init(name) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rake-latex/latex.rb', line 74

def init(name)
  @name = Rake.rootdir + name.to_s.ext("tex")
  @need_aux = true
  @figures = []
  @references = []
  @includes = []
  @include_dirs = []
  @latexinputs = nil
  @pdflatexinputs = nil
  @bibtexinputs = nil

  @tex = @name
  @blank = @tex.ext('')
  @dvi = @tex.ext("dvi")
  @ps  = @tex.ext("ps")
  @pdf = @tex.ext("pdf")
end