Class: LaTeXProjectTemplate::Latexmk

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/latex_project_template/task.rb

Constant Summary collapse

COMMAND_TO_PRODUCE_FILE =
[:dvi, :ps, :pdf, :pdfdvi, :pdfps]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLatexmk

Returns a new instance of Latexmk.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/latex_project_template/task.rb', line 41

def initialize()
  @path = 'latexmk'
  @command = {}

  COMMAND_TO_PRODUCE_FILE.each do |type|
    set(type) do |target|
      "#{@path} -#{type.to_s} #{target}"
    end
  end
  set(:clean) do |target|
    "#{@path} -c"
  end
  set(:distclean) do |target|
    "#{@path} -C"
  end
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



39
40
41
# File 'lib/latex_project_template/task.rb', line 39

def path
  @path
end

Instance Method Details

#command(sym, target) ⇒ Object



62
63
64
# File 'lib/latex_project_template/task.rb', line 62

def command(sym, target)
  @command[sym] && @command[sym].call(target)
end

#execute_command(sym, target) ⇒ Object



66
67
68
69
70
# File 'lib/latex_project_template/task.rb', line 66

def execute_command(sym, target)
  if c = command(sym, target)
    sh(c)
  end
end

#set(sym, &block) ⇒ Object



58
59
60
# File 'lib/latex_project_template/task.rb', line 58

def set(sym, &block)
  @command[sym] = block
end