ruby-graphviz 0.9.7 → 0.9.8

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/lib/graphviz/edge.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
1
+ # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Gregoire Lejeune <gregoire.lejeune@free.fr>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -124,7 +124,7 @@ class GraphViz
124
124
  xAttr = ""
125
125
  xSeparator = ""
126
126
  @oAttrEdge.data.each do |k, v|
127
- xAttr << xSeparator + k + " = " + GraphViz.escape(v, true)
127
+ xAttr << xSeparator + k + " = " + v.to_gv
128
128
  xSeparator = ", "
129
129
  end
130
130
  if xAttr.length > 0
data/lib/graphviz/node.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
1
+ # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Gregoire Lejeune <gregoire.lejeune@free.fr>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -56,7 +56,13 @@ class GraphViz
56
56
  # Get the value of the node attribut +xAttrName+
57
57
  #
58
58
  def []( xAttrName )
59
- @oAttrNode[xAttrName.to_s].clone
59
+ if Hash === xAttrName
60
+ xAttrName.each do |key, value|
61
+ self[key] = value
62
+ end
63
+ else
64
+ @oAttrNode[xAttrName.to_s].clone
65
+ end
60
66
  end
61
67
 
62
68
  #
@@ -112,9 +118,9 @@ class GraphViz
112
118
  xSeparator = ""
113
119
  @oAttrNode.data.each do |k, v|
114
120
  if k == "html"
115
- xAttr << xSeparator + "label = <" + v + ">"
121
+ xAttr << xSeparator + "label = " + v.to_gv
116
122
  else
117
- xAttr << xSeparator + k + " = " + GraphViz.escape(v, true)
123
+ xAttr << xSeparator + k + " = " + v.to_gv
118
124
  end
119
125
  xSeparator = ", "
120
126
  end
@@ -1,3 +1,18 @@
1
+ # Copyright (C) 2009 Gregoire Lejeune <gregoire.lejeune@free.fr>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1
16
  require 'rubygems'
2
17
  require 'treetop'
3
18
 
@@ -0,0 +1,21 @@
1
+ class GraphViz
2
+ class Types
3
+ class Common
4
+ def initialize( data )
5
+ @data = check(data)
6
+ end
7
+
8
+ def output
9
+ return @data
10
+ end
11
+ end
12
+
13
+ Dir.glob( File.dirname( File.expand_path(__FILE__) )+"/types/*" ).each do |f|
14
+ autoload File.basename(f).gsub(File.extname(f), "").split( "_" ).map{|n| n.capitalize }.join.to_sym, f
15
+ end
16
+ end
17
+ end
18
+
19
+ #x = :EscString
20
+ #GraphViz::Types.const_get(x).new( "toto" )
21
+
@@ -0,0 +1,29 @@
1
+ # >> x = "hello\n\t\\l\"world\""
2
+ # => "hello\n\t\\l\"world\""
3
+ # >> puts x.inspect.gsub( "\\\\", "\\" )
4
+ # "hello\n\t\l\"world\""
5
+ #
6
+ # OR
7
+ #
8
+ # >> x = 'hello\n\t\l"world"'
9
+ # => "hello\\n\\t\\l\"world\""
10
+ # >> puts x.inspect.gsub( "\\\\", "\\" )
11
+ # "hello\n\t\l\"world\""
12
+
13
+
14
+ class GraphViz
15
+ class Types
16
+ class EscString < Common
17
+ def check(data)
18
+ return data
19
+ end
20
+
21
+ def output
22
+ return @data.to_s.inspect.gsub( "\\\\", "\\" )
23
+ end
24
+
25
+ alias :to_gv :output
26
+ alias :to_s :output
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ class GraphViz
2
+ class Types
3
+ class HtmlString < Common
4
+ def check(data)
5
+ return data
6
+ end
7
+
8
+ def output
9
+ return "<"+@data+">"
10
+ end
11
+
12
+ alias :to_gv :output
13
+ alias :to_s :output
14
+ end
15
+ end
16
+ end
data/lib/graphviz/xml.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
1
+ # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Gregoire Lejeune <gregoire.lejeune@free.fr>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
data/test/test_init.rb ADDED
@@ -0,0 +1,46 @@
1
+ require 'test/unit'
2
+ $:.unshift("../lib")
3
+ require 'graphviz'
4
+
5
+ class GraphVizTest < Test::Unit::TestCase
6
+ def setup
7
+ @graph = GraphViz::new( :G )
8
+ end
9
+
10
+ # def teardown
11
+ # end
12
+
13
+ def test_graph
14
+ assert(@graph, 'Create graph faild.')
15
+
16
+ assert_block 'Set attribut for graph faild.' do
17
+ @graph['size'] = "10,10"
18
+ end
19
+
20
+ assert_equal( "\"10,10\"", @graph['size'].to_s, 'Get attribut for graph faild.' )
21
+
22
+ assert_equal( "G", @graph.name, "Wrong graph name." )
23
+ end
24
+
25
+ def test_node
26
+ n, m = nil, nil
27
+
28
+ assert_block 'Create node failed.' do
29
+ n = @graph.add_node( "n1" )
30
+ end
31
+
32
+ assert_block 'Get node failed.' do
33
+ m = @graph.get_node( "n1" )
34
+ end
35
+
36
+ assert_equal( m, n, "Node corrupted when get." )
37
+
38
+ assert_equal( @graph.node_count, 1, "Wrong number of nodes" )
39
+
40
+ assert_block 'Set attribut for node faild.' do
41
+ n['label'] = "Hello\n\"world\"\\l"
42
+ end
43
+
44
+ assert_equal( "\"Hello\\n\\\"world\\\"\\l\"", n['label'].to_s, 'Get attribut for node faild.' )
45
+ end
46
+ end
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.7
4
+ version: 0.9.8
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-12-21 00:00:00 +01:00
12
+ date: 2010-01-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -26,6 +26,7 @@ description: Ruby/Graphviz provides an interface to layout and generate images o
26
26
  email: gregoire.lejeune@free.fr
27
27
  executables:
28
28
  - ruby2gv
29
+ - gem2gv
29
30
  extensions: []
30
31
 
31
32
  extra_rdoc_files:
@@ -39,6 +40,7 @@ files:
39
40
  - README.rdoc
40
41
  - AUTHORS
41
42
  - setup.rb
43
+ - bin/gem2gv
42
44
  - bin/ruby2gv
43
45
  - examples/arrowhead.rb
44
46
  - examples/dot/cluster.dot
@@ -59,6 +61,7 @@ files:
59
61
  - examples/graphviz.org/process.rb
60
62
  - examples/graphviz.org/TrafficLights.rb
61
63
  - examples/HTML-Labels.rb
64
+ - examples/maketest.bat
62
65
  - examples/maketest.sh
63
66
  - examples/p2p.rb
64
67
  - examples/sample01.rb
@@ -88,6 +91,12 @@ files:
88
91
  - examples/sample25.rb
89
92
  - examples/sample26.rb
90
93
  - examples/sample27.rb
94
+ - examples/sample28.rb
95
+ - examples/sample29.rb
96
+ - examples/sample30.rb
97
+ - examples/sdlshapes/README
98
+ - examples/sdlshapes/sdl.ps
99
+ - examples/sdlshapes/sdlshapes.dot
91
100
  - examples/shapes.rb
92
101
  - examples/test.xml
93
102
  - examples/testorder.rb
@@ -98,8 +107,12 @@ files:
98
107
  - lib/graphviz/edge.rb
99
108
  - lib/graphviz/node.rb
100
109
  - lib/graphviz/parser.rb
110
+ - lib/graphviz/types/esc_string.rb
111
+ - lib/graphviz/types/html_string.rb
112
+ - lib/graphviz/types.rb
101
113
  - lib/graphviz/xml.rb
102
114
  - lib/graphviz.rb
115
+ - test/test_init.rb
103
116
  has_rdoc: true
104
117
  homepage: http://raa.ruby-lang.org/project/ruby-graphviz/
105
118
  licenses: []