Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve DSL

  • Loading branch information...
commit 4c417a014617f52da343ebdd457f86af0f0b974b 1 parent 818e3d9
Gregoire Lejeune authored
Showing with 20 additions and 28 deletions.
  1. +10 −28 README.rdoc
  2. +9 −0 examples/sample65.rb
  3. +1 −0  lib/graphviz/node.rb
38 README.rdoc
View
@@ -261,6 +261,15 @@ The same but with a block
g.world( :label => "World" ) << g.hello( :label => "Hello" )
}.output( :png => "hello_world.png" )
+Or with the DSL
+
+ require 'graphviz/dsl'
+ digraph :G do
+ world[:label => "World"] << hello[:label => "Hello"]
+
+ output :png => "hello_world.png"
+ end
+
Create a graph from a file
require 'graphviz'
@@ -284,33 +293,6 @@ GraphML[http://graphml.graphdrawing.org/] support
g = GraphViz::GraphML.new( "graphml/cluster.graphml" )
g.graph.output( :path => "/usr/local/bin", :png => "#{$0}.png" )
-At last, you can create family tree with GraphViz::FamilyTree (<b>beta</b>) :
-
- require 'graphviz/family_tree'
-
- tree = GraphViz::FamilyTree.new do
- generation do
- benoist.is_a_man( "Benoist" )
- nathalie.is_a_woman( "Nathalie" )
-
- benoist.is_maried_with nathalie
- end
-
- generation do
- charlotte.is_a_woman( "Charlotte" )
- amelie.is_a_woman( "Amelie" )
- clement.is_a_man( "Clement" )
- gregoire.is_a_man( "Gregoire" )
-
- muriel.is_a_woman( "Muriel" )
-
- gregoire.is_maried_with muriel
- end
-
- couple( benoist, nathalie ).kids( charlotte, amelie, clement, gregoire )
- end
-
- tree.graph.save( :png => "#{$0}.png" )
== TOOLS
@@ -393,7 +375,7 @@ Ruby/GraphViz also includes :
sudo gem install ruby-graphviz
-You also need to install GraphViz[http://www.graphviz.org] and Treetop[http://treetop.rubyforge.org/]
+You also need to install GraphViz[http://www.graphviz.org]
On *Windows* you also need to install win32-open3. This is not an absolute requirement.
9 examples/sample65.rb
View
@@ -0,0 +1,9 @@
+$:.unshift("../lib")
+
+require 'graphviz/dsl'
+digraph :G do
+ world[:label => "World"] << hello[:label => "Hello"]
+ #world << hello
+
+ output :png => "#{$0}.png"
+end
1  lib/graphviz/node.rb
View
@@ -78,6 +78,7 @@ def []( xAttrName )
xAttrName.each do |key, value|
self[key] = value
end
+ return self
else
(@oAttrNode[xAttrName.to_s].nil?)?nil:@oAttrNode[xAttrName.to_s].clone
end
Please sign in to comment.
Something went wrong with that request. Please try again.