Class: Texas::Build::Task::OpenPDF

Inherits:
Base
  • Object
show all
Defined in:
lib/texas/build/task/open_pdf.rb

Constant Summary collapse

DEFAULT_OPEN_CMD =
"evince"

Instance Attribute Summary

Attributes inherited from Base

#build

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Texas::Build::Task::Base

Instance Method Details

#cmdObject



7
8
9
# File 'lib/texas/build/task/open_pdf.rb', line 7

def cmd
  @cmd ||= scripts && scripts['open']
end

#open_pdf_cmdObject



24
25
26
27
28
29
30
31
# File 'lib/texas/build/task/open_pdf.rb', line 24

def open_pdf_cmd
  if cmd
    cmd
  else
    default = `which #{DEFAULT_OPEN_CMD}`.strip
    default.empty? ? nil : default
  end
end

#runObject



15
16
17
18
19
20
21
22
# File 'lib/texas/build/task/open_pdf.rb', line 15

def run
  return unless build.options.open_pdf
  if open_pdf_cmd
    system "#{open_pdf_cmd} #{build.dest_file}"
  else
    puts "Can't open PDF: no default command recognized. Specify in #{CONFIG_FILE}"
  end
end

#scriptsObject



11
12
13
# File 'lib/texas/build/task/open_pdf.rb', line 11

def scripts
  build.config['script']
end