Class: Tex2Rtf

Inherits:
CLApp show all
Includes:
FileUtils
Defined in:
lib/rakeutils/tex2rtf.rb

Overview

Implements programmatic control of the Tex2Rtf application.

Instance Method Summary collapse

Methods inherited from CLApp

#execute, #normalize_dir_path, #quote_all_values, #quote_value, #rubyize_path, #windowize_path

Constructor Details

#initializeTex2Rtf

Constructor



25
26
27
# File 'lib/rakeutils/tex2rtf.rb', line 25

def initialize()
  super( find_app )
end

Instance Method Details

#find_appObject

initialize



29
30
31
32
33
34
35
36
37
38
# File 'lib/rakeutils/tex2rtf.rb', line 29

def find_app
  if Ktutils::OS.windows?
    app_home = ENV["TEX2RTF_HOME"]
    unless app_home.nil? or app_home.empty?
      app_path = File.join(app_home, "tex2rtf.exe")
    end
  else
    raise "cannot use tex2rtf on linux based systems"
  end
end

#generate_help_files(src_path, dest_path) ⇒ Object

Generate help files.

src_path

Source file [.tex]. Path must use forward slashes.

dest_path

Destination file. Path must use forward slashes.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rakeutils/tex2rtf.rb', line 43

def generate_help_files(src_path, dest_path)
  src_dir = File.dirname( File.expand_path( src_path ) )
  src_file = File.basename( src_path )
  dest_path = File.expand_path( dest_path )
  dest_dir = File.dirname( dest_path )

  puts "src_dir: #{src_dir}"
  puts "src_path: #{src_path}"
  puts "dest_dir: #{dest_dir}"
  puts "dest_path: #{dest_path}"

  # Create the destination dir if it doesn't exits.
  if( !File.exists?( dest_dir ) )
    File.makedirs( dest_dir, true )
  end

  cmd_line = "#{src_file} #{dest_path} -checkcurleybraces -checksyntax -html"

  cur_dir = pwd
  cd( src_dir )
    begin
      execute( cmd_line, false )
    rescue
      # do nothing
    end
  cd( cur_dir )
end