From 50465581305b94059fa5f90707e7660360bedd25 Mon Sep 17 00:00:00 2001 From: ellson Date: Wed, 14 Oct 2009 17:11:21 +0000 Subject: [PATCH] fixes to ruby demo from: Ralf Mueller --- tclpkg/gv/demo/modgraph.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tclpkg/gv/demo/modgraph.rb b/tclpkg/gv/demo/modgraph.rb index 6c24a5df2..2b6fa8fba 100755 --- a/tclpkg/gv/demo/modgraph.rb +++ b/tclpkg/gv/demo/modgraph.rb @@ -2,8 +2,9 @@ # display the kernel module dependencies -#author: Patricio Ros -# based on: modgraph.tcl by John Ellson +#based on: modgraph.tcl by: John Ellson +#ruby adaptation by: Patricio Ros +#additional fixes: Ralph Mueller require 'gv' @@ -21,14 +22,15 @@ Gv.setv(N, 'fontsize', '8') Gv.setv(N, 'fontname', 'helvetica') Gv.setv(E, 'arrowsize', '.4') -File.readlines("/proc/modules").each do |rec| - fields = rec.split(' ') - n = Gv.node(G, fields[0]) - fields[3].split(',').find_all {|i| not ['-',' '].include? i}.each do |usedby| - Gv.edge(n, Gv.node(G, usedby)) - end -end +modules = File.open('/proc/modules', mode="r").readlines + +modules.each {|rec| + fields = rec.split(' ') + n = Gv.node(G, fields[0]) + fields[3].split(',').each {|usedby| + Gv.edge(n, Gv.node(G, usedby)) if (usedby != '-') and (usedby != '') + } +} Gv.layout(G, 'dot') Gv.render(G, 'xlib') - -- 2.40.0