module RubyPandoc::Dependencies

Public Instance Methods

satisfied?() click to toggle source
# File lib/ruby-pandoc/dependencies.rb, line 15
def satisfied?
  has_pandoc
  has_latex
end
satisfy() click to toggle source
# File lib/ruby-pandoc/dependencies.rb, line 20
def satisfy
  get_pandoc
  get_latex
end

Private Instance Methods

get_latex() click to toggle source
# File lib/ruby-pandoc/dependencies.rb, line 56
def get_latex
  system('sudo apt-get install -y --force-yes texlive')
end
get_pandoc() click to toggle source

FIXME make this conditional to different types of platforms

# File lib/ruby-pandoc/dependencies.rb, line 46
def get_pandoc
  return if has_pandoc
  Dir.mktmpdir do |dir|
    Dir.chdir(dir) do
      system("wget #{PANDOC_URL} -O pandoc.deb")
      system("sudo dpkg -i pandoc.deb")
    end
  end
end
has_latex() click to toggle source
# File lib/ruby-pandoc/dependencies.rb, line 41
def has_latex
  find_executable 'pdflatex'
end
has_pandoc() click to toggle source
# File lib/ruby-pandoc/dependencies.rb, line 27
def has_pandoc
  pandoc = find_executable 'pandoc'
  unless pandoc
    puts 'Pandoc is not installed'
    return false
  end
  version = `#{pandoc} -v`.lines.first.split(/\s+/).last
  unless Gem::Version.new(version) > Gem::Version.new(PANDOC_MIN_VERSION)
    puts "Pandoc version #{version} too old (require #{PANDOC_MIN_VERSION})"
    return false
  end
  true
end