class Rake4LaTeX::Rail

Support rail-diagramms in LaTeX.

Details for the rail package see www.ctan.org/tex-archive/support/rail/

end

Attributes

cmd[R]

Command line to start rail

stderr[R]
stdout[R]

Public Class Methods

new(source, logger = Log4r::Logger.new('log')) click to toggle source
# File lib/rake4latex/rail.rb, line 9
def initialize(source, logger = Log4r::Logger.new('log'))
  @source = source
  @log = logger
  @cmd = Rake4LaTeX.build_cmd( 'rail', :railfile => source )
end

Public Instance Methods

execute() click to toggle source

Execute rail and returns the result.

rail.exe does not support filenames longer with 8 characters. So we use stdin:

rail < input.rai

Returns successcode (true/false)

end

# File lib/rake4latex/rail.rb, line 29
def execute
  #execute
  @log.debug("Call rail: #{@cmd}")
  stdin, stdout, stderr, wait_thr = Open3.popen3(@cmd)
  
  #analyse result
  success = true
  #check return code
  if wait_thr.value.exitstatus != 0
    @log.fatal("There where Rail errors.")
    success = false
  end
  @stdout = stdout.readlines.join
  @stderr = stderr.readlines.join
  #check errors
  @stderr.each_line{|errline|
    @log.error("Rail error: #{errline.strip}")
    success = false
  }
  
  if ! success
    @log.warn("No rail diagramms generated")
  end

  #Now we have to save the result and delete some stuff.
  if @stdout
    @stdout.sub!(/^(This is Rail.*)/, '') #%This is Rail, Version 1.1 #0
    @stdout.sub!(/^(\(stdin.*)/, '')  
    @stdout.sub!(/^\)/, '')         #last line
    @stdout.strip!
  end
  
  success
end