Permalink
Browse files

Merge pull request #62 from kachick/improve/remove_some_warnings

Remove some warnings
  • Loading branch information...
2 parents efeb4dc + 6406615 commit b1595e3719ad84299e5ddd021ae7d3bd962bf94f @glejeune committed Mar 12, 2013
Showing with 33 additions and 32 deletions.
  1. +5 −5 examples/sample38.rb
  2. +20 −20 lib/graphviz.rb
  3. +1 −1 lib/graphviz/core_ext.rb
  4. +1 −0 lib/graphviz/dot_script.rb
  5. +2 −2 lib/graphviz/edge.rb
  6. +3 −3 lib/graphviz/theory.rb
  7. +1 −1 test/test_subgraph.rb
View
10 examples/sample38.rb
@@ -2,11 +2,11 @@
$:.unshift( "../lib" )
require "graphviz"
-g = GraphViz::new( :G ) { |g|
- g.a[:label => "ε"]
- g.add_nodes( "b", :label => "ε" )
- g.c[:label => 'ε']
- g.add_nodes( "d", :label => 'ε' )
+g = GraphViz::new( :G ) { |_g|
+ _g.a[:label => "ε"]
+ _g.add_nodes( "b", :label => "ε" )
+ _g.c[:label => 'ε']
+ _g.add_nodes( "d", :label => 'ε' )
}
puts g.output( :none => String, :png => "#{$0}.png", :path => "/usr/local/bin" )
View
40 lib/graphviz.rb
@@ -44,31 +44,31 @@ class GraphViz
## Var: Output format (dot, png, jpeg, ...)
@@format = nil #"canon"
- @format
+ @format = nil
## Var: Output file name
- @filename
+ @filename = nil
## Var: Output format and file
- @output
+ @output = nil
## Var: program to use (dot|twopi)
@@prog = "dot"
- @prog
+ @prog = nil
## Var: program path
@@path = []
- @path
+ @path = nil
## Var: Error level
@@errors = 1
- @errors
+ @errors = nil
## Var: External libraries
@@extlibs = []
- @extlibs
+ @extlibs = nil
## Var: Graph name
- @name
+ @name = nil
## Var: defined attributes
- @graph
- @node
- @edge
+ @graph = nil
+ @node = nil
+ @edge = nil
# This accessor allow you to set global graph attributes
attr_accessor :graph
@@ -82,7 +82,7 @@ class GraphViz
attr_accessor :edge
alias_method :edge_attrs, :edge
- @elements_order
+ @elements_order = nil
#<b>DEPRECATED</b> please use GraphViz#add_nodes
def add_node( xNodeName, hOpts = {} )
@@ -484,7 +484,7 @@ def output( hOpts = {} )
begin
require 'graphviz/nothugly'
@nothugly = true
- rescue LoadError => e
+ rescue LoadError
warn "You must install ruby-xslt or libxslt-ruby to use nothugly option!"
@nothugly = false
end
@@ -764,7 +764,7 @@ def complete!
# Return true if the graph is directed.
def directed?
- not (/digraph/ =~ "bla digraph bla").nil?
+ not((/digraph/ =~ "bla digraph bla").nil?)
end
def has_parent_graph?
@@ -775,15 +775,15 @@ def has_parent_graph?
private
## Var: Nodes, Edges and Graphs tables
- @hoNodes
- @loEdges
- @hoGraphs
+ @hoNodes = nil
+ @loEdges = nil
+ @hoGraphs = nil
## Var: Parent graph
- @oParentGraph
+ @oParentGraph = nil
## Var: Type de graphe (orienté ou non)
- @oGraphType
+ @oGraphType = nil
#
# Create a new graph object
@@ -914,7 +914,7 @@ def self.generate(num_nodes, num_edges, directed = false, weight_range = (1..1))
end
nodes = (1..num_nodes).map{ |e| e.to_s }
- x = g.add_nodes(nodes)
+ g.add_nodes(nodes)
edges = []
nodes.each do |head|
View
2 lib/graphviz/core_ext.rb
@@ -17,7 +17,7 @@ class Object
def to_ruby
begin
eval self
- rescue => e
+ rescue
self
end
end
View
1 lib/graphviz/dot_script.rb
@@ -4,6 +4,7 @@ class GraphViz
class DOTScriptData
def initialize
@data = []
+ @separator = nil
end
def append(data)
View
4 lib/graphviz/edge.rb
@@ -45,7 +45,7 @@ def initialize( vNodeOne, vNodeTwo, parent_graph )
# Return the node one as string (so with port if any)
def node_one( with_port = true )
- if not (@node_one_port and with_port)
+ if not(@node_one_port and with_port)
GraphViz.escape(@node_one_id)
else
GraphViz.escape(@node_one_id, :force => true) + ":#{@node_one_port}"
@@ -55,7 +55,7 @@ def node_one( with_port = true )
# Return the node two as string (so with port if any)
def node_two( with_port = true )
- if not (@node_two_port and with_port)
+ if not(@node_two_port and with_port)
GraphViz.escape(@node_two_id)
else
GraphViz.escape(@node_two_id, :force => true) + ":#{@node_two_port}"
View
6 lib/graphviz/theory.rb
@@ -150,8 +150,8 @@ def critical_path
return nil if range.include?(nil) or @graph.type != "digraph"
r = [ [0, [1]] ]
- critical_path_recursion( distance_matrix, adjancy_matrix, r, [], 0 ).inject( {:distance => 0, :path => []} ) { |r, item|
- (r[:distance] < item[0]) ? { :distance => item[0], :path => item[1] } : r
+ critical_path_recursion( distance_matrix, adjancy_matrix, r, [], 0 ).inject( {:distance => 0, :path => []} ) { |_r, item|
+ (_r[:distance] < item[0]) ? { :distance => item[0], :path => item[1] } : _r
}
end
@@ -309,7 +309,7 @@ def critical_path_recursion( d, a, r, result, level )
cpath = [ (p[0] + d[node,succ]), (p[1].clone << succ) ]
if index_of_item( a.line(succ), 1 ).size > 0
- capth = critical_path_recursion( d, a, [cpath], result, level+1 )
+ critical_path_recursion( d, a, [cpath], result, level+1 )
else
result << cpath
end
View
2 test/test_subgraph.rb
@@ -5,7 +5,7 @@
class GraphVizSubGraphTest < Test::Unit::TestCase
def test_subgraph
master1 = GraphViz::new(:G)
- cl1 = master1.add_graph('cluster_cl1')
+ master1.add_graph('cluster_cl1')
master2 = GraphViz::new(:G)
cl2 = GraphViz::new('cluster_cl1')

0 comments on commit b1595e3

Please sign in to comment.