The option keys that should be included in the dot output.
Given a Dataset, parse the internal structure to generate a dataset visualization.
# File lib/sequel/extensions/to_dot.rb, line 19 19: def initialize(ds) 20: @i = 0 21: @stack = [@i] 22: @dot = ["digraph G {", "0 [label=\"self\"];"] 23: v(ds, "") 24: @dot << "}" 25: end
Add an entry to the dot output with the given label. If j is given, it is used directly as the node or transition. Otherwise a node is created for the current object.
# File lib/sequel/extensions/to_dot.rb, line 37 37: def dot(label, j=nil) 38: @dot << "#{j||@i} [label=#{label.to_s.inspect}];" 39: end
Recursive method that parses all of Sequel’s internal datastructures, adding the appropriate nodes and transitions to the internal dot structure.
# File lib/sequel/extensions/to_dot.rb, line 44 44: def v(e, l) 45: @i += 1 46: dot(l, "#{@stack.last} -> #{@i}") if l 47: @stack.push(@i) 48: case e 49: when LiteralString 50: dot "#{e.inspect}.lit" # core_sql use 51: when Symbol, Numeric, String, Class, TrueClass, FalseClass, NilClass 52: dot e.inspect 53: when Array 54: dot "Array" 55: e.each_with_index do |val, j| 56: v(val, j) 57: end 58: when Hash 59: dot "Hash" 60: e.each do |k, val| 61: v(val, k) 62: end 63: when SQL::ComplexExpression 64: dot "ComplexExpression: #{e.op}" 65: e.args.each_with_index do |val, j| 66: v(val, j) 67: end 68: when SQL::Identifier 69: dot "Identifier" 70: v(e.value, :value) 71: when SQL::QualifiedIdentifier 72: dot "QualifiedIdentifier" 73: v(e.table, :table) 74: v(e.column, :column) 75: when SQL::OrderedExpression 76: dot "OrderedExpression: #{e.descending ? :DESC : :ASC}#{" NULLS #{e.nulls.to_s.upcase}" if e.nulls}" 77: v(e.expression, :expression) 78: when SQL::AliasedExpression 79: dot "AliasedExpression" 80: v(e.expression, :expression) 81: v(e.aliaz, :alias) 82: when SQL::CaseExpression 83: dot "CaseExpression" 84: v(e.expression, :expression) if e.expression 85: v(e.conditions, :conditions) 86: v(e.default, :default) 87: when SQL::Cast 88: dot "Cast" 89: v(e.expr, :expr) 90: v(e.type, :type) 91: when SQL::Function 92: dot "Function: #{e.f}" 93: e.args.each_with_index do |val, j| 94: v(val, j) 95: end 96: when SQL::Subscript 97: dot "Subscript" 98: v(e.f, :f) 99: v(e.sub, :sub) 100: when SQL::WindowFunction 101: dot "WindowFunction" 102: v(e.function, :function) 103: v(e.window, :window) 104: when SQL::Window 105: dot "Window" 106: v(e.opts, :opts) 107: when SQL::PlaceholderLiteralString 108: str = e.str 109: str = "(#{str})" if e.parens 110: dot "PlaceholderLiteralString: #{str.inspect}" 111: v(e.args, :args) 112: when SQL::JoinClause 113: str = "#{e.join_type.to_s.upcase} JOIN" 114: if e.is_a?(SQL::JoinOnClause) 115: str << " ON" 116: elsif e.is_a?(SQL::JoinUsingClause) 117: str << " USING" 118: end 119: dot str 120: v(e.table, :table) 121: v(e.table_alias, :alias) if e.table_alias 122: if e.is_a?(SQL::JoinOnClause) 123: v(e.on, :on) 124: elsif e.is_a?(SQL::JoinUsingClause) 125: v(e.using, :using) 126: end 127: when Dataset 128: dot "Dataset" 129: TO_DOT_OPTIONS.each do |k| 130: if val = e.opts[k] 131: v(val, k.to_s) 132: end 133: end 134: else 135: dot "Unhandled: #{e.inspect}" 136: end 137: @stack.pop 138: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.