class Mkbook::Utils

Public Class Methods

command_exists?(command) click to toggle source
# File lib/mkbook/utils.rb, line 17
def self.command_exists?(command)
  if File.executable?(command) then
    return command
  end
  ENV['PATH'].split(File::PATH_SEPARATOR).map do |path|
    cmd = "#{path}/#{command}"
    File.executable?(cmd) || File.executable?("#{cmd}.exe") || File.executable?("#{cmd}.cmd")
  end.inject { |a, b| a || b }
end
log(type, msg) click to toggle source
# File lib/mkbook/utils.rb, line 27
def self.log(type, msg)
  print "[#{type}] #{Time.now} #{msg}"
end
log_debug(msg) click to toggle source
# File lib/mkbook/utils.rb, line 39
def self.log_debug(msg)
  log("DEBUG", msg)
end
log_error(msg) click to toggle source
# File lib/mkbook/utils.rb, line 35
def self.log_error(msg)
  log("ERROR", msg)
end
log_info(msg) click to toggle source
# File lib/mkbook/utils.rb, line 31
def self.log_info(msg)
  log("INFO", msg)
end
post_pandoc(string) click to toggle source
# File lib/mkbook/utils.rb, line 11
def self.post_pandoc(string)
  replace = Replace.new(string)
  replace.post_pandoc_for_latex
  replace.string
end
pre_pandoc(string) click to toggle source
# File lib/mkbook/utils.rb, line 5
def self.pre_pandoc(string)
  replace = Replace.new(string)
  replace.pre_pandoc_for_latex
  replace.string
end