Class: Teapot::Command::Visualize

Inherits:
Selection
  • Object
show all
Defined in:
lib/teapot/command/visualize.rb

Instance Method Summary collapse

Methods inherited from Selection

#call, #selection, #targets

Instance Method Details

#dependency_nameObject



38
39
40
# File 'lib/teapot/command/visualize.rb', line 38

def dependency_name
  @options[:dependency_name]
end

#dependency_namesObject



34
35
36
# File 'lib/teapot/command/visualize.rb', line 34

def dependency_names
  @targets || []
end

#process(selection) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/teapot/command/visualize.rb', line 42

def process(selection)
  context = selection.context
  chain = selection.chain

  if dependency_name
    provider = selection.dependencies[dependency_name]
    
    chain = chain.partial(provider)
  end

  visualization = ::Build::Dependency::Visualization.new

  graph = visualization.generate(chain)

  if output_path = @options[:output_path]
    Graphviz.output(graph, path: output_path, format: :svg)
  else
    $stdout.puts graph.to_dot
  end

  return graph
end