ruby-graphviz 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ end
5
5
  #
6
6
  # For the bool type,
7
7
  # - TRUE values are represented by "true" or "yes" (case-insensitive), true and any non-zero integer
8
- # - FALSE values by "false" or "no" (case-insensitive), false and zero.
8
+ # - FALSE values by "false", "no" or empty string (case-insensitive), false and zero.
9
9
  #
10
10
  # Example
11
11
  #
@@ -18,10 +18,10 @@ class GraphViz
18
18
  class Types
19
19
  class GvBool < Common
20
20
  BOOL_TRUE = ["true", "yes"]
21
- BOOL_FALSE = ["false", "no"]
21
+ BOOL_FALSE = ["false", "no", ""]
22
22
 
23
23
  def check(data)
24
- if true == data or (data.is_a?(Integer) and data != 0) or (data.is_a?(String) and BOOL_TRUE.include?(data.downcase))
24
+ if true == data or (data.is_a?(Integer) and data != 0) or (data.is_a?(String) and !BOOL_FALSE.include?(data.downcase))
25
25
  @to_ruby = true
26
26
  return data
27
27
  end
@@ -11,7 +11,9 @@ class GraphViz
11
11
  return data
12
12
  end
13
13
 
14
- raise DoubleException, "Invalid double value"
14
+ return nil if data.is_a?(String) and data.empty?
15
+
16
+ raise DoubleException, "Invalid double value for `#{data}`"
15
17
  end
16
18
 
17
19
  def output
@@ -15,6 +15,7 @@ class GraphViz
15
15
  if data.is_a?(Array)
16
16
  return check(data.join(","))
17
17
  end
18
+ return nil if data.is_a?(String) and data.empty?
18
19
 
19
20
  raise RectException, "Invalid rect value"
20
21
  end
@@ -35,6 +35,8 @@ class GraphViz
35
35
  @is_spline = false
36
36
  return data
37
37
  end
38
+ return nil if data.empty?
39
+
38
40
  raise SplineTypeException, "Invalid spline type value"
39
41
  end
40
42
 
data/lib/graphviz/xml.rb CHANGED
@@ -42,12 +42,12 @@ class GraphViz
42
42
  # * xml_file : XML File
43
43
  # * *options : Graph options:
44
44
  # * :text : show text nodes (default true)
45
- # * :attrs : show XML attributs (default true)
45
+ # * :attrs : show XML attributes (default true)
46
46
  #
47
47
  def initialize( xml_file, *options )
48
48
  @node_name = "00000"
49
49
  @show_text = true
50
- @show_attributs = true
50
+ @show_attributes = true
51
51
 
52
52
  if options.nil? == false and options[0].nil? == false
53
53
  options[0].each do |xKey, xValue|
@@ -56,7 +56,7 @@ class GraphViz
56
56
  @show_text = xValue
57
57
  options[0].delete( xKey )
58
58
  when "attrs"
59
- @show_attributs = xValue
59
+ @show_attributes = xValue
60
60
  options[0].delete( xKey )
61
61
  end
62
62
  end
@@ -72,7 +72,7 @@ class GraphViz
72
72
  @node_name.succ!
73
73
 
74
74
  label = xml_node.name
75
- if xml_node.has_attributes? == true and @show_attributs == true
75
+ if xml_node.has_attributes? == true and @show_attributes == true
76
76
  label = "{ " + xml_node.name
77
77
 
78
78
  xml_node.attributes.each do |xName, xValue|
@@ -104,7 +104,7 @@ class GraphViz
104
104
  end
105
105
  end
106
106
 
107
- ## Act: Search and add attributs
107
+ ## Act: Search and add attributes
108
108
  ## TODO
109
109
 
110
110
  xml_node.each_element( ) do |xml_child_node|
data/lib/graphviz.rb CHANGED
@@ -64,65 +64,38 @@ class GraphViz
64
64
  ## Var: Graph name
65
65
  @name
66
66
 
67
- ## Var: defined attributs
67
+ ## Var: defined attributes
68
68
  @graph
69
69
  @node
70
70
  @edge
71
71
 
72
- # This accessor allow you to set global graph attributs
72
+ # This accessor allow you to set global graph attributes
73
73
  attr_accessor :graph
74
74
  alias_method :graph_attrs, :graph
75
75
 
76
- # This accessor allow you to set global nodes attributs
76
+ # This accessor allow you to set global nodes attributes
77
77
  attr_accessor :node
78
78
  alias_method :node_attrs, :node
79
79
 
80
- # This accessor allow you to set global edges attributs
80
+ # This accessor allow you to set global edges attributes
81
81
  attr_accessor :edge
82
82
  alias_method :edge_attrs, :edge
83
83
 
84
84
  @elements_order
85
85
 
86
- ##
86
+ #<b>DEPRECATED</b> please use GraphViz#add_nodes
87
+ def add_node( xNodeName, hOpts = {} )
88
+ warn "GraphViz#add_node is deprecated, please use GraphViz#add_nodes"
89
+ return add_nodes(xNodeName, hOpts)
90
+ end
91
+
87
92
  # Create a new node
88
93
  #
89
94
  # In:
90
95
  # * xNodeName : Name of the new node
91
- # * hOpts : Node attributs
96
+ # * hOpts : Node attributes
92
97
  #
93
98
  # Return the GraphViz::Node object created
94
- #
95
- def add_node( xNodeName, hOpts = {} )
96
- warn "GraphViz#add_node is deprecated, please use GraphViz#add_nodes"
97
- return add_nodes(xNodeName, hOpts)
98
- =begin
99
- node = @hoNodes[xNodeName]
100
-
101
- if node.nil?
102
- @hoNodes[xNodeName] = GraphViz::Node::new( xNodeName, self )
103
- @hoNodes[xNodeName].index = @elements_order.size_of( "node" )
104
-
105
- unless hOpts.keys.include?(:label) or hOpts.keys.include?("label")
106
- hOpts[:label] = xNodeName
107
- end
108
-
109
- @elements_order.push( {
110
- "type" => "node",
111
- "name" => xNodeName,
112
- "value" => @hoNodes[xNodeName]
113
- } )
114
-
115
- node = @hoNodes[xNodeName]
116
- end
117
-
118
- hOpts.each do |xKey, xValue|
119
- @hoNodes[xNodeName][xKey.to_s] = xValue
120
- end
121
-
122
- return node
123
- =end
124
- end
125
-
126
99
  def add_nodes(node_name, options = {})
127
100
  if node_name.kind_of? Array
128
101
  node_name.each { |n| add_nodes(n, options.clone) }
@@ -206,7 +179,7 @@ class GraphViz
206
179
  @hoNodes.size
207
180
  end
208
181
 
209
- #<b>DEPRECATED</b>
182
+ #<b>DEPRECATED</b> please use GraphViz#add_edges
210
183
  def add_edge( oNodeOne, oNodeTwo, hOpts = {} )
211
184
  warn "GraphViz#add_edge is deprecated, please use GraphViz#add_edges"
212
185
  add_edges(oNodeOne, oNodeTwo, hOpts)
@@ -217,7 +190,7 @@ class GraphViz
217
190
  # In:
218
191
  # * node_one : First node (or node list)
219
192
  # * node_two : Second Node (or node list)
220
- # * options : Edge attributs
193
+ # * options : Edge attributes
221
194
  def add_edges( node_one, node_two, options = {} )
222
195
 
223
196
  if( node_one.class == Array )
@@ -281,7 +254,7 @@ class GraphViz
281
254
  #
282
255
  # In:
283
256
  # * xGraphName : Graph name
284
- # * hOpts : Graph attributs
257
+ # * hOpts : Graph attributes
285
258
  #
286
259
  def add_graph( xGraphName = nil, hOpts = {}, &block )
287
260
  if xGraphName.kind_of?(GraphViz)
@@ -393,7 +366,7 @@ class GraphViz
393
366
  end
394
367
 
395
368
  #
396
- # Set value +xValue+ to the graph attribut +xAttrName+
369
+ # Set value +xValue+ to the graph attribute +xAttrName+
397
370
  #
398
371
  def []=( xAttrName, xValue )
399
372
  xValue = xValue.to_s if xValue.class == Symbol
@@ -401,7 +374,7 @@ class GraphViz
401
374
  end
402
375
 
403
376
  #
404
- # Get the value of the graph attribut +xAttrName+
377
+ # Get the value of the graph attribute +xAttrName+
405
378
  #
406
379
  def []( xAttrName )
407
380
  if Hash === xAttrName
@@ -414,14 +387,18 @@ class GraphViz
414
387
  end
415
388
 
416
389
  #
417
- # Calls block once for each attribut of the graph, passing the name and value to the
390
+ # Calls block once for each attribute of the graph, passing the name and value to the
418
391
  # block as a two-element array.
419
392
  #
420
- def each_attribut(&b)
393
+ def each_attribute(&b)
421
394
  @graph.each do |k,v|
422
395
  yield(k,v)
423
396
  end
424
397
  end
398
+ def each_attribut(&b)
399
+ warn "`GraphViz#each_attribut` is deprecated, please use `GraphViz#each_attribute`"
400
+ each_attribute(&b)
401
+ end
425
402
 
426
403
  #
427
404
  # Generate the graph
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.rubyforge_project = 'ruby-asp'
23
23
  s.has_rdoc = true
24
- s.extra_rdoc_files = ["README.rdoc", "COPYING", "AUTHORS"]
24
+ s.extra_rdoc_files = ["README.rdoc", "COPYING.rdoc", "AUTHORS.rdoc", "CHANGELOG.rdoc"]
25
25
  s.rdoc_options = ["--title", "Ruby/GraphViz", "--main", "README.rdoc"]
26
26
  s.post_install_message = %{
27
27
  Since version 0.9.2, Ruby/GraphViz can use Open3.popen3 (or not)
@@ -34,12 +34,14 @@ For more information about Ruby-Graphviz :
34
34
  * Sources : http://github.com/glejeune/Ruby-Graphviz
35
35
  * NEW - Mailing List : http://groups.google.com/group/ruby-graphviz
36
36
 
37
- /!\\ GraphViz#add_edge is deprecated, use GraphViz#add_edges
38
- /!\\ GraphViz#add_node is deprecated, use GraphViz#add_nodes
37
+ Last (important) changes :
38
+ * GraphViz#add_edge is deprecated, use GraphViz#add_edges
39
+ * GraphViz#add_node is deprecated, use GraphViz#add_nodes
40
+ * GraphViz::Edge#each_attribut is deprecated, use GraphViz::Edge#each_attribute
41
+ * GraphViz::GraphML#attributs is deprecated, use GraphViz::GraphML#attributes
42
+ * GraphViz::Node#each_attribut is deprecated, use GraphViz::Node#each_attribute
39
43
  }
40
44
 
41
- # s.add_runtime_dependency("middleman", "~>2.0.0.3")
42
-
43
45
  s.add_development_dependency 'rake'
44
46
  s.add_development_dependency 'gems'
45
47
  s.add_development_dependency 'rdoc'
data/test/test_types.rb CHANGED
@@ -55,11 +55,13 @@ class TypesTest < Test::Unit::TestCase
55
55
  assert_equal false, bool.to_ruby
56
56
 
57
57
  assert_raise BoolException, "Wrong bool value" do
58
- GraphViz::Types::GvBool.new("toto")
58
+ GraphViz::Types::GvBool.new(:toto)
59
59
  end
60
60
 
61
- assert_raise BoolException, "Wrong bool value" do
62
- GraphViz::Types::GvBool.new("")
61
+ assert_block "Create GvBool with empty string failed." do
62
+ bool = GraphViz::Types::GvBool.new("")
63
63
  end
64
+ assert bool
65
+ assert_equal false, bool.to_ruby
64
66
  end
65
67
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-graphviz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 3
10
- version: 1.0.3
9
+ - 4
10
+ version: 1.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gregoire Lejeune
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-17 00:00:00 Z
18
+ date: 2012-01-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake
@@ -71,14 +71,16 @@ extensions: []
71
71
 
72
72
  extra_rdoc_files:
73
73
  - README.rdoc
74
- - COPYING
75
- - AUTHORS
74
+ - COPYING.rdoc
75
+ - AUTHORS.rdoc
76
+ - CHANGELOG.rdoc
76
77
  files:
77
78
  - .gemrc
78
79
  - .gitignore
79
80
  - .travis.yml
80
- - AUTHORS
81
- - COPYING
81
+ - AUTHORS.rdoc
82
+ - CHANGELOG.rdoc
83
+ - COPYING.rdoc
82
84
  - Gemfile
83
85
  - README.rdoc
84
86
  - Rakefile
@@ -184,6 +186,7 @@ files:
184
186
  - examples/sample66.rb
185
187
  - examples/sample67.rb
186
188
  - examples/sample68.rb
189
+ - examples/sample69.rb
187
190
  - examples/sample99.rb
188
191
  - examples/sdlshapes/README
189
192
  - examples/sdlshapes/sdl.ps
@@ -246,8 +249,12 @@ post_install_message: "\n\
246
249
  * Doc : http://rdoc.info/projects/glejeune/Ruby-Graphviz\n\
247
250
  * Sources : http://github.com/glejeune/Ruby-Graphviz\n\
248
251
  * NEW - Mailing List : http://groups.google.com/group/ruby-graphviz\n\n\
249
- /!\\ GraphViz#add_edge is deprecated, use GraphViz#add_edges\n\
250
- /!\\ GraphViz#add_node is deprecated, use GraphViz#add_nodes\n "
252
+ Last (important) changes :\n\
253
+ * GraphViz#add_edge is deprecated, use GraphViz#add_edges\n\
254
+ * GraphViz#add_node is deprecated, use GraphViz#add_nodes\n\
255
+ * GraphViz::Edge#each_attribut is deprecated, use GraphViz::Edge#each_attribute\n\
256
+ * GraphViz::GraphML#attributs is deprecated, use GraphViz::GraphML#attributes\n\
257
+ * GraphViz::Node#each_attribut is deprecated, use GraphViz::Node#each_attribute\n "
251
258
  rdoc_options:
252
259
  - --title
253
260
  - Ruby/GraphViz
data/AUTHORS DELETED
@@ -1,23 +0,0 @@
1
- Gregoire Lejeune <glejeune.lejeune@free.fr>
2
- Brandon Coleman <metrix1978@gmail.com>
3
- Dave Burt <http://github.com/dburt>
4
- Miguel Cabrera <http://mfcabrera.com>
5
- obruening <http://github.com/obruening>
6
- reactive <http://github.com/reactive>
7
- Hugh Sasse <hgs@dmu.ac.uk>
8
- axgle <http://github.com/axgle>
9
- hipe <http://github.com/hipe>
10
- Stefan Huber <http://github.com/MSNexploder>
11
- Nigel Thorne <http://github.com/NigelThorne>
12
- Rolf Timmermans <http://github.com/rolftimmermans>
13
- Jonas Elfström <http://github.com/jonelf>
14
- oupo <http://github.com/oupo>
15
- Daniel Zollinger <https://github.com/dznz>
16
- Ronen Barzel <https://github.com/ronen>
17
- Jamison Dance <https://github.com/jergason>
18
- hirochachacha <https://github.com/hirochachacha>
19
-
20
- Thanks to :
21
-
22
- Desmond Dsouza - Windows tests and corrections
23
- Vidar Hokstad and Ryan Shea - for nothugly.xsl