Skip to content

Commit

Permalink
Add compatibility for Ruby 1.8
Browse files Browse the repository at this point in the history
Resolves backtrace:

$ iblinkinfo.pl | /tmp/topology.rb -f svg -o top1
/tmp/topology.rb:230: wrong argument type Symbol (expected Proc) (TypeError)
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:152:in `instance_eval'
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:152:in `initialize'
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:567:in `new'
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:567:in `digraph'
  from /tmp/topology.rb:210

Tested-by: Paul Morgan <jumanjiman@gmail.com>

Tested on these Ruby versions:
* RHEL 5:    ruby 1.8.5 (2006-08-25) [x86_64-linux]
* RHEL 6:    ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
* Fedora 17: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Test procedure:
I saved the output from iblinkinfo in a test environment, then
provided that as input for this patch using each version of Ruby listed above.
  • Loading branch information
jumanjiman committed Sep 19, 2012
1 parent f8fb938 commit dfcff4e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion topology.rb
Expand Up @@ -225,8 +225,10 @@ def port_label(i, ports, color)
else else
proc { |e| true } proc { |e| true }
end end

id_mapper = proc { |e| e.sw_id }


sw_list = links.select(&lid_filter).map(&:sw_id).uniq sw_list = links.select(&lid_filter).map(&id_mapper).uniq


sw_list.each do |id| sw_list.each do |id|
ports = (1..36).to_a.map { |e| "<p%d> %d" % [e, e] }.join("|") ports = (1..36).to_a.map { |e| "<p%d> %d" % [e, e] }.join("|")
Expand Down

0 comments on commit dfcff4e

Please sign in to comment.