Sha256: aacb18034825a9a84db938e1bf77287fa593fa19033250fb4abd5e99f067606b
Contents?: true
Size: 818 Bytes
Versions: 6
Compression:
Stored size: 818 Bytes
Contents
module Lapidarius class Tree CURVED = "└── " EMPTY = " " NESTED = "├── " STRAIGHT = "│ " def initialize(gem) @gem = gem @out = [] end def to_s return @out unless @out.empty? @out.tap do |out| out << @gem recurse out << "" out << "#{@gem.count} runtime, #{@gem.dev_count} development" end end private def recurse(gem = @gem, prefix = "") last_index = gem.size - 1 gem.each_with_index do |dep, i| pointer, preadd = branches(i == last_index) @out << "#{prefix}#{pointer}#{dep}" recurse(dep, "#{prefix}#{preadd}") if dep.size > 0 end end private def branches(last) return [CURVED, EMPTY] if last [NESTED, STRAIGHT] end end end
Version data entries
6 entries across 6 versions & 1 rubygems