Class: Dot2Ruby

Inherits:
Object show all
Includes:
GraphViz::Utils
Defined in:
lib/graphviz/dot2ruby.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from GraphViz::Utils

#find_executable, #output_and_errors_from_command, #output_from_command

Constructor Details

#initialize(xGVPath, xOutFile, xOutFormat = nil) ⇒ Dot2Ruby

:nodoc:



24
25
26
27
28
29
30
# File 'lib/graphviz/dot2ruby.rb', line 24

def initialize( xGVPath, xOutFile, xOutFormat = nil ) #:nodoc:
  paths = (xGVPath.nil?) ? [] : [xGVPath]
  @xGvprPath = find_executable( 'gvpr', paths )
  @xOutFile = xOutFile
  @xOutFormat = xOutFormat || "_"
  @gvprScript = GraphViz::Ext.find( "dot2ruby.g" )
end

Instance Method Details

#eval(xFile) ⇒ Object

:nodoc:



44
45
46
47
48
49
# File 'lib/graphviz/dot2ruby.rb', line 44

def eval( xFile ) #:nodoc:
  xCmd = [@xGvprPath, '-f', @gvprScript, '-a', '-', xFile]
  xOutput = output_from_command( xCmd )
  instance_eval(xOutput)
  return @_graph_eval
end

#eval_string(data) ⇒ Object

:nodoc:



51
52
53
54
55
56
57
58
# File 'lib/graphviz/dot2ruby.rb', line 51

def eval_string( data ) #:nodoc:
  t = Tempfile::open( File.basename(__FILE__) )
  t.print( data )
  t.close
  result = self.eval(t.path)
  t.close
  return result
end

#run(xFile) ⇒ Object

:nodoc:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/graphviz/dot2ruby.rb', line 32

def run( xFile ) #:nodoc:
  xCmd = [@xGvprPath, '-f', @gvprScript, '-a', @xOutFormat, xFile]
  xOutput = output_from_command( xCmd )
  if @xOutFile.nil?
    puts xOutput
  else
    File.open( @xOutFile, "w" ) do |io|
      io.print xOutput
    end
  end
end