Permalink
Browse files

Merge pull request #50 from markus1189/cleanup_format

Cleanup format
  • Loading branch information...
2 parents 0eb693b + 1b9d1e3 commit 179c8850ea5dc7dd1a97038450e3ce982b94bbcd @glejeune committed Jul 3, 2012
Showing with 723 additions and 728 deletions.
  1. +5 −5 bin/dot2ruby
  2. +18 −18 bin/gem2gv
  3. +20 −20 bin/git2gv
  4. +26 −26 bin/ruby2gv
  5. +5 −5 bin/xml2gv
  6. +5 −5 examples/sample06.rb
  7. +3 −3 examples/sample12.rb
  8. +8 −8 examples/sample13.rb
  9. +8 −8 examples/sample14.rb
  10. +1 −1 examples/sample15.rb
  11. +7 −7 examples/sample17.rb
  12. +10 −10 examples/sample19.rb
  13. +2 −2 examples/sample20.rb
  14. +1 −1 examples/sample21.rb
  15. +1 −1 examples/sample28.rb
  16. +1 −1 examples/sample31.rb
  17. +10 −10 examples/sample33.rb
  18. +1 −1 examples/sample34.rb
  19. +7 −7 examples/sample35.rb
  20. +2 −2 examples/sample36.rb
  21. +4 −4 examples/sample40.rb
  22. +72 −72 examples/sample44.rb
  23. +4 −4 examples/sample45.rb
  24. +7 −7 examples/sample48.rb
  25. +1 −1 examples/sample50.rb
  26. +2 −2 examples/sample52.rb
  27. +2 −2 examples/sample53.rb
  28. +3 −3 examples/sample54.rb
  29. +2 −2 examples/sample60.rb
  30. +2 −2 examples/sample61.rb
  31. +2 −2 examples/sample62.rb
  32. +15 −15 examples/sample99.rb
  33. +2 −2 examples/theory/pert.rb
  34. +2 −2 examples/theory/tests.rb
  35. +140 −140 lib/graphviz.rb
  36. +6 −11 lib/graphviz/attrs.rb
  37. +34 −34 lib/graphviz/constants.rb
  38. +1 −1 lib/graphviz/core_ext.rb
  39. +7 −7 lib/graphviz/dot2ruby.rb
  40. +5 −5 lib/graphviz/dsl.rb
  41. +13 −13 lib/graphviz/edge.rb
  42. +5 −5 lib/graphviz/elements.rb
  43. +1 −1 lib/graphviz/ext.rb
  44. +15 −15 lib/graphviz/family_tree.rb
  45. +11 −11 lib/graphviz/family_tree/couple.rb
  46. +6 −6 lib/graphviz/family_tree/generation.rb
  47. +13 −13 lib/graphviz/family_tree/person.rb
  48. +39 −39 lib/graphviz/graphml.rb
  49. +23 −23 lib/graphviz/math/matrix.rb
  50. +8 −8 lib/graphviz/node.rb
  51. +3 −3 lib/graphviz/nothugly.rb
  52. +8 −8 lib/graphviz/theory.rb
  53. +3 −3 lib/graphviz/types.rb
  54. +3 −3 lib/graphviz/types/arrow_type.rb
  55. +2 −2 lib/graphviz/types/color.rb
  56. +2 −2 lib/graphviz/types/color_list.rb
  57. +2 −2 lib/graphviz/types/esc_string.rb
  58. +3 −3 lib/graphviz/types/gv_bool.rb
  59. +3 −3 lib/graphviz/types/gv_double.rb
  60. +2 −2 lib/graphviz/types/html_string.rb
  61. +2 −2 lib/graphviz/types/lbl_string.rb
  62. +2 −2 lib/graphviz/types/rect.rb
  63. +9 −9 lib/graphviz/types/spline_type.rb
  64. +11 −11 lib/graphviz/utils.rb
  65. +35 −35 lib/graphviz/utils/colors.rb
  66. +24 −24 lib/graphviz/xml.rb
  67. +4 −4 setup.rb
  68. +9 −9 test/test_graph.rb
  69. +4 −4 test/test_theory.rb
  70. +4 −4 test/test_utils_colors.rb
View
@@ -1,16 +1,16 @@
#!/usr/bin/env ruby
# Copyright (C) 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -20,7 +20,7 @@ require 'graphviz/constants'
require 'graphviz/dot2ruby'
require 'getoptlong'
-def usage
+def usage
puts "usage: dot2ruby [-ofile] [-Tformat] [-h] [-V] script"
puts "-o, --output-file file Output file"
puts "-T, --output-format format Output format (default: nil)"
@@ -83,7 +83,7 @@ end
xFile = ARGV[0]
-if xFile.nil? == true
+if xFile.nil?
usage( )
exit
end
View
@@ -1,16 +1,16 @@
#!/usr/bin/env ruby
# Copyright (C) 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -22,24 +22,24 @@ require 'getoptlong'
class Gem2Gv
def initialize( xGVPath, xUse )
@oGraph = GraphViz::new( :G, :path => xGVPath, :use => xUse )
-
+
@nodes = []
@name = 'gem2gv'
end
-
+
def out( xFormat = "dot", xFile = nil )
- if xFile.nil? == true
+ if xFile.nil?
@oGraph.output( xFormat => String )
else
@oGraph.output( xFormat => xFile )
end
end
-
+
def go( gemName, version = ">0" )
nodes = getDependency(gemName, version)
-
+
createEdges( gemName, version, nodes )
-
+
nodes.each do |node|
unless @nodes.include?(node)
@nodes << node
@@ -50,41 +50,41 @@ class Gem2Gv
def getDependency( gemName, version = ">0" )
nodes = []
-
+
dependency = Gem::Dependency.new( gemName, version )
fetcher = Gem::SpecFetcher.fetcher
-
+
fetcher.find_matching(dependency).each do |spec_tuple, source_uri|
spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
-
+
spec.dependencies.each do |dep|
#nodes << { :name => dep.name, :version => dep.version_requirements.to_s} unless nodes.include?({ :name => dep.name, :version => dep.version_requirements.to_s})
nodes << { :name => dep.name, :version => ">0" } unless nodes.include?({ :name => dep.name, :version => ">0" })
end
end
-
+
return nodes
end
-
+
def getNode( name, version )
#nodeName = "#{name}#{version}"
#nodeLabel = "#{name}\n#{version}"
nodeName = "#{name}"
nodeLabel = "#{name}"
return @oGraph.get_node(nodeName) || @oGraph.add_nodes( nodeName, "label" => nodeLabel )
end
-
+
def createEdges( gemName, version, nodes )
nodeA = getNode( gemName, version )
-
+
nodes.each do |node|
nodeB = getNode( node[:name], node[:version] )
@oGraph.add_edges( nodeA, nodeB )
end
end
end
-def usage
+def usage
puts "usage: gem2gv [-Tformat] [-ofile] [-h] [-V] gemname"
puts "-T, --output-format format Output format (default: PNG)"
puts "-o, --output-file file Output file (default: STDOUT)"
@@ -154,7 +154,7 @@ end
xGem = ARGV[0]
-if xGem.nil? == true
+if xGem.nil?
usage( )
exit
end
View
@@ -1,16 +1,16 @@
#!/usr/bin/env ruby
# Copyright (C) 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -23,41 +23,41 @@ class Git2Gv
def initialize( xGVPath, xOutFile, xOutFormat, bNothugly )
@xGVPath, @xOutFile, @xOutFormat, @bNothugly = xGVPath, xOutFile, xOutFormat.to_sym, bNothugly
end
-
+
def run
git = GraphViz.new( :G, :path => @xGVPath )
-
+
git.node[:shape => "record"]
-
+
branches.each do |branch|
git.add_nodes( branch, :style => "filled", :fillcolor => :lightgrey )
end
-
+
commits.each do |commit|
- git.add_nodes(
- commit[:short],
+ git.add_nodes(
+ commit[:short],
:style => "filled",
:fillcolor => :lightblue,
- :label => "{ #{commit[:long]} |{ #{commit[:comment].gsub(/\{/, "\\{").gsub(/\}/, "\\}").gsub(/\|/, "\\|").gsub(/</, "\\<").gsub(/>/, "\\>")}}| { #{commit[:commiter]} | #{commit[:date]} } }"
+ :label => "{ #{commit[:long]} |{ #{commit[:comment].gsub(/\{/, "\\{").gsub(/\}/, "\\}").gsub(/\|/, "\\|").gsub(/</, "\\<").gsub(/>/, "\\>")}}| { #{commit[:commiter]} | #{commit[:date]} } }"
)
end
-
+
refs.each do |from, to|
git.add_edges( from, to )
end
-
+
relations.each do |from, to|
git.add_edges( to, from, :dir => "back" )
end
-
+
git.output( @xOutFormat => @xOutFile, :nothugly => @bNothugly )
end
-
+
# private
def cmd(c, &blk)
`#{c}`.split($/).map(&blk || proc {|a| a })
end
-
+
def commits
@commits ||= begin
data = []
@@ -74,30 +74,30 @@ class Git2Gv
data
end
end
-
+
def relations
@rels ||= cmd("git log --pretty=format:\"%h %p\"") { |l|
c, *parents = l.split
parents.map {|p| [p, c] }
}.flatten(1)
end
-
+
def branches
@branches ||= cmd("git branch") {|b| b[2..-1] }
end
-
+
def refs
branches.inject({}) {|h,b|
h.tap { h[b] = `git log -1 #{b} --pretty=format:"%h"` }
}
end
-
+
def current_branch
cmd("git branch").select {|l| l =~ /^\*/ }.first.strip[2..-1]
end
end
-def usage
+def usage
puts "usage: git2gv [-Tformat] [-ofile] [-h] [-V]"
puts "-T, --output-format format Output format (default: png)"
puts " --nothugly Use nothugly if SVG output"
Oops, something went wrong.

0 comments on commit 179c885

Please sign in to comment.