lib/gizzard/commands.rb in gizzmo-0.3.2 vs lib/gizzard/commands.rb in gizzmo-0.3.3

- old
+ new

@@ -63,26 +63,26 @@ class SubtreeCommand < Command def run @roots = [] argv.each do |arg| @id = ShardId.parse(arg) - @roots << up(@id) + @roots += roots_of(@id) end @roots.uniq.each do |root| output root.to_unix down(root, 1) end end - def up(id) + def roots_of(id) links = service.list_upward_links(id) if links.empty? - id + [id] else - links.map { |link| link.up_id }.find { |up_id| up(up_id) } + links.map { |link| roots_of(link.up_id) }.flatten end end - + def down(id, depth = 0) service.list_downward_links(id).map do |link| printable = " " * depth + link.down_id.to_unix output printable down(link.down_id, depth + 1)