Class: Tap::Tasks::PrintTree

Inherits:
Tap::Task
  • Object
show all
Defined in:
lib/tap/tasks/print_tree.rb

Overview

:startdoc::manifest print a directory tree

Prints a directory tree using a nice algorithm from www.xxeo.com/archives/2007/06/06/a-simple-directory-tree-printer-in-ruby.html

The output format is like this:

sample
|- MIT-LICENSE
|- README
|- Rakefile
|- lib
|   `- sample.rb
|- sample.gemspec
|- tap.yml
`- test
    |- sample_test.rb
    |- tap_test_helper.rb
    `- tap_test_suite.rb

Constant Summary collapse

ARM_MAP =
Hash.new("|   ")

Instance Method Summary collapse

Instance Method Details

#hidden?(path) ⇒ Boolean

Returns true if the path is hidden. If the hidden_files config is specified as true, then hidden? always returns false, indicating that under these conditions no path is considered hidden.

Returns:

  • (Boolean)


44
45
46
# File 'lib/tap/tasks/print_tree.rb', line 44

def hidden?(path)
  !hidden_files && path.to_s =~ /^\.[^\.]/
end

#process(*paths) ⇒ Object



33
34
35
36
37
38
# File 'lib/tap/tasks/print_tree.rb', line 33

def process(*paths)
  paths << "." if paths.empty?
  paths.map { |path| visit(Pathname.new("."), "", "", "", Pathname.new(path)) }
  
  nil
end