Module: RDot
- Defined in:
- lib/rdot.rb
Constant Summary collapse
- VERSION =
'1.0.4'
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.
-
.snapshot(opts = {}) ⇒ Hash
Make hash with data of objectspace.
Class Method Details
.defaults ⇒ Hash
Default values for dot options.
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/rdot.rb', line 392 def defaults { :graph_fontname => 'sans-serif', :graph_fontsize => 24, :graph_label => 'RDot Graph', :node_fontname => 'monospace', :node_fontsize => 9, :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' } end |
.diff(base, other, opts = {}) ⇒ Hash
Make diff between two objectspaces.
365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/rdot.rb', line 365 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.
684 685 686 687 688 689 690 691 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 |
# File 'lib/rdot.rb', line 684 def dot space, opts = {} opts = defaults.merge opts result = [] result << 'digraph graph_RDot{' result << ' graph[' result << ' rankdir=LR,' result << ' splines=true,' result << ' labelloc=t,' 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 << ' arrowtail=vee,' result << ' penwidth=0.5, arrowsize=0.5' result << ' ];' @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=8,' 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 |
.snapshot(opts = {}) ⇒ Hash
Make hash with data of objectspace.
297 298 299 300 301 302 |
# File 'lib/rdot.rb', line 297 def snapshot opts = {} opts = defaults.merge opts result = {} ObjectSpace.each_object(Module) { |m| add_module result, m, opts } result end |