Class: Teapot::Command::Visualize

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

Instance Method Summary collapse

Instance Method Details

#dependency_nameObject



40
41
42
# File 'lib/teapot/command/visualize.rb', line 40

def dependency_name
  @options[:dependency_name]
end

#dependency_namesObject



36
37
38
# File 'lib/teapot/command/visualize.rb', line 36

def dependency_names
  @targets || []
end

#invoke(parent) ⇒ Object



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

def invoke(parent)
  context = parent.context
  selection = context.select(dependency_names)
  chain = selection.chain

  if dependency_name
    provider = selection.dependencies[dependency_name]
    
    # TODO The visualisation generated isn't quite right. It's introspecting too much from the packages and not reflecting #ordered and #provisions.
    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)
  end

  return graph
end