class Courgette::Commands::Graph

Public Class Methods

new(options) click to toggle source
# File lib/courgette/commands/graph.rb, line 7
def initialize options
  @options = options
end

Public Instance Methods

run() click to toggle source
# File lib/courgette/commands/graph.rb, line 11
def run
  factory.load filtered_graph

  formats.each do |fmt|
    factory.save name, fmt
  end
end

Private Instance Methods

factory() click to toggle source
# File lib/courgette/commands/graph.rb, line 32
def factory
  @factory ||= Courgette::Graph2Dot.new do
    boxes
    node_attribs << filled
  end
end
filter_nodes() click to toggle source
# File lib/courgette/commands/graph.rb, line 43
def filter_nodes
  return nil if @options.filter.nil?

  @options.filter.split(',').map do |root|
    root.split("::").map(&:to_sym)
  end
end
filtered_graph() click to toggle source
# File lib/courgette/commands/graph.rb, line 39
def filtered_graph
  @filtered_graph ||= graph.filter filter_nodes
end
formats() click to toggle source
# File lib/courgette/commands/graph.rb, line 24
def formats
  Array(@options.format)
end
glob() click to toggle source
# File lib/courgette/commands/graph.rb, line 20
def glob
  @options.glob
end
graph() click to toggle source
# File lib/courgette/commands/graph.rb, line 51
def graph
  @graph ||= Courgette::DirectoryAnalyser.new.tap do |da|
    da.analyse glob
  end.graph
end
name() click to toggle source
# File lib/courgette/commands/graph.rb, line 28
def name
  @options.name
end