Module: RDot
- Defined in:
- lib/rdot.rb,
lib/rdot-common.rb
Constant Summary collapse
- VERSION =
'1.1.1'
Class Method Summary collapse
-
.defaults ⇒ Hash
Default values for RDot.dot options.
-
.diff(base, other, opts = {}) ⇒ Hash
Make diff between two objectspaces.
-
.dot(space, opts = {}) ⇒ String
Make .dot text from snapshot or difference.
- .get_file(file) ⇒ Object
-
.snapshot(opts = {}) ⇒ Hash
Make hash with data of objectspace.
Class Method Details
.defaults ⇒ Hash
Default values for dot options.
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/rdot.rb', line 386 def defaults { :graph_fontname => 'sans-serif', :graph_fontsize => 24, :graph_label => 'RDot Graph', :node_fontname => 'monospace', :node_fontsize => 9, :color_class => '#77FF77', :color_class_preloaded => '#AAFFAA', :color_class_core => '#DDFFDD', :color_exception => '#FF7777', :color_exception_preloaded => '#FFAAAA', :color_exception_core => '#FFDDDD', :color_module => '#9999FF', :color_module_preloaded => '#BBBBFF', :color_module_core => '#DDDDFF', # :color_class => '#BBFFBB', # :color_class_preloaded => '#CCEECC', # :color_class_core => '#DDFF99', # :color_exception => '#FFBBBB', # :color_exception_preloaded => '#EECCCC', # :color_exception_core => '#FFDD99', # :color_module => '#BBBBFF', # :color_module_preloaded => '#CCCCEE', # :color_module_core => '#99DDFF', :color_protected => '#EEEEEE', :color_private => '#DDDDDD', :color_inherited => '#0000FF', :color_included => '#00AAFF', :color_extended => '#AA00FF', :color_nested => '#EEEEEE', :graph_splines => 'spline' } end |
.diff(base, other, opts = {}) ⇒ Hash
Make diff between two objectspaces.
359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/rdot.rb', line 359 def diff base, other, opts = {} opts = defaults.merge opts if other == nil return base end result = {} base.each do |n, m| d = diff_module m, other[n], opts result[n] = d if d end result end |
.dot(space, opts = {}) ⇒ String
Make .dot text from snapshot or difference.
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File 'lib/rdot.rb', line 692 def dot space, opts = {} opts = defaults.merge opts result = [] result << 'digraph graph_RDot{' result << ' graph[' result << ' rankdir=RL,' result << ' splines=' + opts[:graph_splines] + ',' result << ' labelloc=t,searchsize=1000,' result << ' fontname="' + opts[:graph_fontname] + '",' result << ' fontsize=' + opts[:graph_fontsize].to_s + ',' result << ' label="' + opts[:graph_label] + '"' result << ' ];' result << ' node[' result << ' shape=plaintext,' result << ' fontname="' + opts[:node_fontname] + '",' result << ' fontsize=' + opts[:node_fontsize].to_s + '' result << ' ];' result << ' edge[' # result << ' dir=back,' # result << ' arrowhead=vee,' result << ' penwidth=0.5, arrowsize=0.5' result << ' ];' result << ' nullnode[label=""];' # result << ' nullnode -> ' + node_name('Kernel') + '[color=yellow,weight=0,minlen=0];' @processed = [] @nested = [] @extended = [] @included = [] @inherited = [] space.each do |n, m| mm = dot_module space, n, m, opts result << ' ' + mm if mm end result << ' subgraph subNested{' result << ' edge[' result << ' color="' + opts[:color_nested] + '",' result << ' weight=1,' result << ' minlen=0' result << ' ];' result << ' ' + @nested.join("\n ") result << ' }' result << ' subgraph subExtended{' result << ' edge[' result << ' color="' + opts[:color_extended] + '",' result << ' weight=1,' result << ' minlen=0' result << ' ];' result << ' ' + @extended.join("\n ") result << ' }' result << ' subgraph subIncluded{' result << ' edge[' result << ' color="' + opts[:color_included] + '",' result << ' weight=2,' result << ' minlen=1' result << ' ];' result << ' ' + @included.join("\n ") result << ' }' result << ' subgraph subInherited{' result << ' edge[' result << ' color="' + opts[:color_inherited] + '",' result << ' weight=4,' result << ' minlen=1' result << ' ];' result << ' ' + @inherited.join("\n ") result << ' }' result << '}' result.join "\n" end |
.get_file(file) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rdot-common.rb', line 9 def get_file file src = File. file $:.each do |dir| dir = File. dir len = dir.length if src[0...len] == dir src = src[len..-1] if src[0] == '/' src = src[1..-1] end return src end end return file end |
.snapshot(opts = {}) ⇒ Hash
Make hash with data of objectspace.
289 290 291 292 293 294 |
# File 'lib/rdot.rb', line 289 def snapshot opts = {} opts = defaults.merge opts result = {} ObjectSpace.each_object(Module) { |m| add_module result, m, opts } result end |