Class: VisualizeRuby::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/visualize_ruby/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#calling_codeString, ...

Returns The code that calls the graphed code.

Returns:

  • (String, File, Pathname, Proc)

    The code that calls the graphed code.



6
7
8
# File 'lib/visualize_ruby/runner.rb', line 6

def calling_code
  @calling_code
end

#in_line_local_method_callsObject



40
41
42
# File 'lib/visualize_ruby/runner.rb', line 40

def in_line_local_method_calls
  @in_line_local_method_calls ||= traced?
end

#only_graphs=(value) ⇒ Object

Sets the attribute only_graphs

Parameters:

  • value

    the value to set the attribute only_graphs to.



18
19
20
# File 'lib/visualize_ruby/runner.rb', line 18

def only_graphs=(value)
  @only_graphs = value
end

#outputObject (readonly)

Returns the value of attribute output.



25
26
27
# File 'lib/visualize_ruby/runner.rb', line 25

def output
  @output
end

#output_formatSymbol, ...

Returns To output DOT format as a string use String class as value.

Returns:

  • (Symbol, NilClass, String)

    To output DOT format as a string use String class as value.



10
11
12
# File 'lib/visualize_ruby/runner.rb', line 10

def output_format
  @output_format
end

#output_pathString, Pathname

Returns Add the exe name to select a format ie. png, jpg, svg, dot…

Returns:

  • (String, Pathname)

    Add the exe name to select a format ie. png, jpg, svg, dot…



12
13
14
# File 'lib/visualize_ruby/runner.rb', line 12

def output_path
  @output_path
end

#ruby_codeString, ...

Returns The code to be graphed.

Returns:

  • (String, File, Pathname)

    The code to be graphed.



8
9
10
# File 'lib/visualize_ruby/runner.rb', line 8

def ruby_code
  @ruby_code
end

#unique_nodes=(value) ⇒ Object

Parameters:

  • Duplicate (TrueClass, FalseClass)

    nodes with the same description are merged to point single node.



16
17
18
# File 'lib/visualize_ruby/runner.rb', line 16

def unique_nodes=(value)
  @unique_nodes = value
end

Instance Method Details

#graphsObject



50
51
52
53
# File 'lib/visualize_ruby/runner.rb', line 50

def graphs
  graphs = builder.graphs.map(&:name).compact
  [builder.options.fetch(:label, "default")].concat(graphs)
end

#options(opts = {}) ⇒ Object



44
45
46
47
48
# File 'lib/visualize_ruby/runner.rb', line 44

def options(opts={})
  opts.each do |key, value|
    public_send("#{key}=", value)
  end
end

#run!Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/visualize_ruby/runner.rb', line 27

def run!
  @run ||= begin
    highlight_trace
    @output ||= VisualizeRuby::Graphviz.new(
      builder,
      graphs:       filter_graphs,
      unique_nodes: unique_nodes,
      only_graphs:  only_graphs,
    ).to_graph({ path: output_path, format: output_format }.compact)
  end
  self
end

#trace(calling_code = nil, &block) ⇒ Object

Parameters:

  • (String, File)
  • (Proc)


21
22
23
# File 'lib/visualize_ruby/runner.rb', line 21

def trace(calling_code = nil, &block)
  @calling_code = calling_code || block
end