class Spoom::FileTree::TreePrinter
See ‘FileTree#print`
An internal class used to print a FileTree
def initialize(tree:, out: $stdout, show_strictness: true, colors: true, indent_level: 0)
def initialize(tree:, out: $stdout, show_strictness: true, colors: true, indent_level: 0) super(out: out, colors: colors, indent_level: indent_level) @tree = tree @show_strictness = show_strictness end
def node_strictness(node)
def node_strictness(node) path = node.path prefix = tree.strip_prefix path = "#{prefix}/#{path}" if prefix Spoom::Sorbet::Sigils.file_strictness(path) end
def print_node(node)
def print_node(node) printt if node.children.empty? if @show_strictness strictness = node_strictness(node) if @colors print_colored(node.name, strictness_color(strictness)) elsif strictness print("#{node.name} (#{strictness})") else print(node.name.to_s) end else print(node.name.to_s) end print("\n") else print_colored(node.name, Color::BLUE) print("/") printn indent print_nodes(node.children.values) dedent end end
def print_nodes(nodes)
def print_nodes(nodes) nodes.each { |node| print_node(node) } end
def print_tree
def print_tree print_nodes(tree.roots) end
def strictness_color(strictness)
def strictness_color(strictness) case strictness when "false" Color::RED when "true", "strict", "strong" Color::GREEN else Color::CLEAR end end