class Webgen::CLI::ShowTreeCommand
The CLI command for showing the node tree.
Private Instance Methods
collect_data(children, selector)
click to toggle source
# File lib/webgen/cli/commands/show_tree.rb, line 52 def collect_data(children, selector) children.sort {|a,b| a.alcn <=> b.alcn}.map do |node| sub = collect_data(node.children, selector) if sub.length > 0 || ((selector.nil? || node.alcn.include?(selector)) && ((!node.is_fragment? || @show_fragments) && (!node['passive'] || command_parser.website.ext.item_tracker.node_referenced?(node)))) data = [@use_alcn ? node.alcn : node.lcn] data << node.alcn data << (@meta_info ? node.meta_info.map {|k,v| "#{k}: #{v.inspect}"} : []) data << sub data else nil end end.compact end
print_tree(data, indent = '', selector)
click to toggle source
# File lib/webgen/cli/commands/show_tree.rb, line 71 def print_tree(data, indent = '', selector) data.each do |name, alcn, info, children| puts("#{indent}#{Utils.light(Utils.blue(name))}") info.each {|i| puts("#{indent} #{i}")} if info.length > 0 && (selector.nil? || alcn.include?(selector)) print_tree(children, indent + ' ', selector) end end