From 3d0abe7e82240b49c6ef003c15b2933d414e25c0 Mon Sep 17 00:00:00 2001 From: Dave Burt Date: Thu, 17 Dec 2009 15:07:10 +1100 Subject: [PATCH] Respect "none" format in output options hash and respect String output-filename when the "none" format is selected. See examples/sample27.rb --- examples/sample27.rb | 8 ++++++++ lib/graphviz.rb | 21 +++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 examples/sample27.rb diff --git a/examples/sample27.rb b/examples/sample27.rb new file mode 100644 index 0000000..901b006 --- /dev/null +++ b/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 ) diff --git a/lib/graphviz.rb b/lib/graphviz.rb index 9e9ec60..811b9ee 100644 --- a/lib/graphviz.rb +++ b/lib/graphviz.rb @@ -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), "." ) @@ -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 @@ -426,8 +425,6 @@ def output( *hOpt ) #end output_from_command( xCmd ) - else - xDOTScript end if xOutputString