ruby-graphviz 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +5 -0
- data/examples/maketest.sh +4 -0
- data/examples/sample24.rb +11 -0
- data/examples/sample24.rb.png +0 -0
- data/lib/graphviz.rb +44 -19
- data/lib/graphviz/constants.rb +1 -1
- data/lib/graphviz/edge.rb +4 -0
- data/lib/graphviz/node.rb +3 -0
- metadata +9 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.9.3 :
|
2
|
+
* Minor bug correction for Windows
|
3
|
+
* Use Open3.popen3 if installed, else use IO.popen (by Dave Burt)
|
4
|
+
* Add '-', '>' and '>>' has aliases of '<<' to create an edge.
|
5
|
+
|
1
6
|
0.9.2 :
|
2
7
|
* Escape nodes (by Dave Burt)
|
3
8
|
* Handle errors from graphviz command (by Dave Burt)
|
data/examples/maketest.sh
CHANGED
Binary file
|
data/lib/graphviz.rb
CHANGED
@@ -16,7 +16,6 @@
|
|
16
16
|
|
17
17
|
require 'tempfile'
|
18
18
|
require 'mkmf'
|
19
|
-
require 'open3'
|
20
19
|
|
21
20
|
require 'graphviz/node'
|
22
21
|
require 'graphviz/edge'
|
@@ -324,7 +323,7 @@ class GraphViz
|
|
324
323
|
else
|
325
324
|
if hOpt.nil? == false and hOpt[0].nil? == false
|
326
325
|
hOpt[0].each do |xKey, xValue|
|
327
|
-
xValue = xValue.to_s unless xValue.nil? or xValue.class
|
326
|
+
xValue = xValue.to_s unless xValue.nil? or [Class, TrueClass, FalseClass].include?(xValue.class)
|
328
327
|
case xKey.to_s
|
329
328
|
when "output"
|
330
329
|
warn ":output option is deprecated, please use :<format> => :<file>"
|
@@ -356,12 +355,14 @@ class GraphViz
|
|
356
355
|
xOutputString = false
|
357
356
|
xOutput = if @format != "none"
|
358
357
|
## Act: Save script and send it to dot
|
359
|
-
t =
|
358
|
+
t = if /Windows/.match( ENV['OS'] )
|
359
|
+
Tempfile::open( File.basename($0), "." )
|
360
|
+
else
|
361
|
+
Tempfile::open( File.basename($0) )
|
362
|
+
end
|
360
363
|
t.print( xDOTScript )
|
361
364
|
t.close
|
362
365
|
|
363
|
-
#cmd = find_executable( @prog )
|
364
|
-
#cmd = find_executable0( @prog )
|
365
366
|
cmd = find_executable( )
|
366
367
|
if cmd == nil
|
367
368
|
raise StandardError, "GraphViz not installed or #{@prog} not in PATH. Install GraphViz or use the 'path' option"
|
@@ -390,21 +391,13 @@ class GraphViz
|
|
390
391
|
end
|
391
392
|
end
|
392
393
|
|
393
|
-
xCmd = "#{cmd} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
|
394
|
-
|
395
|
-
|
396
|
-
#
|
397
|
-
|
398
|
-
|
399
|
-
errors = stderr.read
|
400
|
-
if errors.blank?
|
401
|
-
stdout.read
|
402
|
-
else
|
403
|
-
raise "Error from graphviz (#{xCmd}):\n#{errors}"
|
404
|
-
end
|
405
|
-
end
|
394
|
+
#xCmd = "#{cmd} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
|
395
|
+
#if /Windows/.match( ENV['OS'] )
|
396
|
+
xCmd = "\"#{cmd}\" #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
|
397
|
+
#end
|
398
|
+
|
399
|
+
output_from_command( xCmd )
|
406
400
|
else
|
407
|
-
#puts xDOTScript
|
408
401
|
xDOTScript
|
409
402
|
end
|
410
403
|
|
@@ -418,6 +411,35 @@ class GraphViz
|
|
418
411
|
|
419
412
|
alias :save :output
|
420
413
|
|
414
|
+
def output_and_errors_from_command(cmd) #:nodoc:
|
415
|
+
unless defined? Open3
|
416
|
+
begin
|
417
|
+
require 'open3'
|
418
|
+
require 'win32/open3'
|
419
|
+
rescue LoadError
|
420
|
+
end
|
421
|
+
end
|
422
|
+
begin
|
423
|
+
Open3.popen3( cmd ) do |stdin, stdout, stderr|
|
424
|
+
stdin.close
|
425
|
+
[stdout.read, stderr.read]
|
426
|
+
end
|
427
|
+
rescue NotImplementedError, NoMethodError
|
428
|
+
IO.popen( cmd ) do |stdout|
|
429
|
+
[stdout.read, nil]
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
def output_from_command(cmd) #:nodoc:
|
435
|
+
output, errors = output_and_errors_from_command(cmd)
|
436
|
+
if errors.nil? || errors.strip.empty?
|
437
|
+
output
|
438
|
+
else
|
439
|
+
raise "Error from #{cmd}:\n#{errors}"
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
421
443
|
#
|
422
444
|
# Get the graph name
|
423
445
|
#
|
@@ -439,6 +461,9 @@ class GraphViz
|
|
439
461
|
return GraphViz::commonGraph( oNode, self ).add_edge( self, oNode )
|
440
462
|
end
|
441
463
|
end
|
464
|
+
alias :> :<<
|
465
|
+
alias :- :<<
|
466
|
+
alias :>> :<<
|
442
467
|
|
443
468
|
def pg #:nodoc:
|
444
469
|
@oParentGraph
|
data/lib/graphviz/constants.rb
CHANGED
data/lib/graphviz/edge.rb
CHANGED
data/lib/graphviz/node.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-graphviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregoire Lejeune
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-19 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -84,6 +84,8 @@ files:
|
|
84
84
|
- examples/sample21.rb
|
85
85
|
- examples/sample22.rb
|
86
86
|
- examples/sample23.rb
|
87
|
+
- examples/sample24.rb
|
88
|
+
- examples/sample24.rb.png
|
87
89
|
- examples/shapes.rb
|
88
90
|
- examples/test.xml
|
89
91
|
- examples/testorder.rb
|
@@ -101,8 +103,11 @@ homepage: http://raa.ruby-lang.org/project/ruby-graphviz/
|
|
101
103
|
licenses: []
|
102
104
|
|
103
105
|
post_install_message: |+
|
104
|
-
|
105
|
-
|
106
|
+
|
107
|
+
Since version 0.9.2, Ruby/GraphViz can use Open3.popen3 (or not)
|
108
|
+
On Windows, you can install 'win32-open3'
|
109
|
+
|
110
|
+
You need to install GraphViz (http://graphviz.org/) to use this Gem.
|
106
111
|
|
107
112
|
rdoc_options:
|
108
113
|
- --title
|