glejeune / Ruby-Graphviz

[MIRROR] Ruby interface to the GraphViz graphing tool
https://gitlab.com/glejeune/ruby-graphviz
Other
608 stars 116 forks source link

Can no longer create binary strings #92

Closed daniel-rikowski closed 10 years ago

daniel-rikowski commented 10 years ago

Commit 8c13e38e1b3b3380ae1717b67ce35a4eaa7b0e7d removed the support for binary strings, i.e. it is no longer possible to create things like in-memory PNGs.

The original code used binary streams:

Open3.popen3( *cmd ) do |stdin, stdout, stderr|
  stdin.close
  stdout.binmode     # Important!
  [stdout.read, stderr.read]
end

The new code does not use binary streams, i.e. the output created by GraphViz are interpreted as UTF-8 strings and not as ASCII-8BIT. Fortunately there is a simple fix to restore the old behaviour:

Change

out, err, status = Open3.capture3(*cmd)

to:

out, err, status = Open3.capture3(*cmd, :binmode => true)

Thank you in advance!