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 52 def collect_data(children, selector) 53 children.sort {|a,b| a.alcn <=> b.alcn}.map do |node| 54 sub = collect_data(node.children, selector) 55 if sub.length > 0 || 56 ((selector.nil? || node.alcn.include?(selector)) && 57 ((!node.is_fragment? || @show_fragments) && 58 (!node['passive'] || command_parser.website.ext.item_tracker.node_referenced?(node)))) 59 data = [@use_alcn ? node.alcn : node.lcn] 60 data << node.alcn 61 data << (@meta_info ? node.meta_info.map {|k,v| "#{k}: #{v.inspect}"} : []) 62 data << sub 63 data 64 else 65 nil 66 end 67 end.compact 68 end
print_tree(data, indent = '', selector)
click to toggle source
# File lib/webgen/cli/commands/show_tree.rb 71 def print_tree(data, indent = '', selector) 72 data.each do |name, alcn, info, children| 73 puts("#{indent}#{Utils.light(Utils.blue(name))}") 74 info.each {|i| puts("#{indent} #{i}")} if info.length > 0 && (selector.nil? || alcn.include?(selector)) 75 print_tree(children, indent + ' ', selector) 76 end 77 end