Skip to content

Commit

Permalink
Respect "none" format in output options hash and respect String outpu…
Browse files Browse the repository at this point in the history
…t-filename when the "none" format is selected. See examples/sample27.rb
  • Loading branch information
dburt committed Dec 17, 2009
1 parent 3afe72a commit 3d0abe7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
8 changes: 8 additions & 0 deletions examples/sample27.rb
@@ -0,0 +1,8 @@
#!/usr/bin/ruby

$:.unshift( "../lib" );
require "graphviz"

puts GraphViz.new(:G){ |g|
(g.hello - g.none) [:style => :bold, :label => " dburt says"]
}.save( :none => String )
21 changes: 9 additions & 12 deletions lib/graphviz.rb
Expand Up @@ -370,8 +370,13 @@ def output( *hOpt )

xDOTScript = "#{@oGraphType} #{@name} {\n" << xDOTScript

xOutputString = false
xOutput = if @format != "none"
xOutputString = (@filename == String ||
@output.any? {|format, file| file == String })

xOutput =
if @format == "none" || @output.has_key?("none")
xDOTScript
else
## Act: Save script and send it to dot
# t = if /Windows/.match( ENV['OS'] )
# Tempfile::open( File.basename($0), "." )
Expand All @@ -395,21 +400,15 @@ def output( *hOpt )
xOutputWithFile = ""
xOutputWithoutFile = ""
unless @format.nil?
if @filename.nil?
xOutputWithoutFile = "-T#{@format} "
elsif @filename == String
if @filename.nil? || @filename == String
xOutputWithoutFile = "-T#{@format} "
xOutputString = true
else
xOutputWithFile = "-T#{@format} -o#{@filename} "
end
end
@output.each do |format, file|
if file.nil?
if file.nil? || file == String
xOutputWithoutFile << "-T#{format} "
elsif file == String
xOutputWithoutFile << "-T#{format} "
xOutputString = true
else
xOutputWithFile << "-T#{format} -o#{file} "
end
Expand All @@ -426,8 +425,6 @@ def output( *hOpt )
#end

output_from_command( xCmd )
else
xDOTScript
end

if xOutputString
Expand Down

0 comments on commit 3d0abe7

Please sign in to comment.