
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
tree.rb is a 'clone' of tree unix command. The gem contains also a library to build tree with a dsl (domain specific language), and an implementation of visitor design pattern.
To use the command line tool tree.rb execute into command line tree.rb --help Try tree.rb -h to get help on command line.
$ tree.rb --help
Usage: tree.rb [options] [directory]
list contents of directories in a tree-like format
this is a almost :-) a clone of tree unix command written in ruby
Code https://github.com/tokiro/treevisitor. Feedback to tokiro.oyama@gmail.com
options:
-h, --help Show this message
--version Show the version
-a All file are listed
-d List directories only
-v, --[no-]verbose Run verbosely
-q, --quiet quiet mode as --no-verbose
-f, --format ALGO select an algo
(b,v,j,y,build-dir,print-dir,json,yaml)
To print the tree of a directory execute tree.rb with the name of the directory. For example:
$ tree.rb lib
lib
|-- tree_visitor.rb
|-- treevisitor.rb
|-- treevisitor_cli.rb
`-- treevisitor
|-- abs_node.rb
|-- dir_processor.rb
|-- dir_tree_walker.rb
|-- leaf_node.rb
|-- tree_node.rb
|-- tree_node_visitor.rb
|-- cli
| `-- cli_tree.rb
`-- visitors
|-- block_tree_node_visitor.rb
|-- build_dir_tree_visitor.rb
|-- callback_tree_node_visitor2.rb
|-- clone_tree_node_visitor.rb
|-- depth_tree_node_visitor.rb
|-- flat_print_tree_node_visitors.rb
|-- print_dir_tree_visitor.rb
`-- print_tree_node_visitor.rb
The tree.rb can generate json structure suitable to be visualized with protovis javascript library. See the examples directory.
$ ruby bin/tree.rb --format json lib
{
"lib": {
"tree_visitor.rb": 45,
"treevisitor": {
"abs_node.rb": 2858,
"basic_tree_node_visitor.rb": 578,
"cli": {
"cli_tree.rb": 2929
},
"directory_walker.rb": 5049,
"leaf_node.rb": 526,
"tree_node.rb": 5665,
"tree_node_visitor.rb": 1263,
"util": {
"dir_processor.rb": 928
},
"visitors": {
"block_tree_node_visitor.rb": 386,
"build_dir_tree_visitor.rb": 1167,
"callback_tree_node_visitor2.rb": 1652,
"clone_tree_node_visitor.rb": 837,
"depth_tree_node_visitor.rb": 427,
"directory_to_hash_visitor.rb": 639,
"flat_print_tree_node_visitors.rb": 341,
"print_dir_tree_visitor.rb": 387,
"print_tree_node_visitor.rb": 707
}
},
"treevisitor.rb": 976,
"treevisitor_cli.rb": 87
}
The json structure can be transformed into image:
See examples directory to use treevisitor in your code.
DSL to build tree:
tree = TreeNode.create do
node "root" do
leaf "l1"
node "sub" do
leaf "l3"
end
node "wo leaves"
end
http://rubydoc.info/gems/tree.rb
To use the command line tool tree.rb, it is enough to install the gem:
[sudo] gem install tree.rb
To use into your project, add this line to your application's Gemfile:
gem 'tree.rb'
And then execute:
$ bundle
Everybody is welcome to contribute to this project by commenting the source code, suggesting modifications or new ideas, reporting bugs, writing some documentation and, of course, you're also welcome to contribute with patches as well!
To contribute:
git checkout -b my-new-feature)git commit -am 'Added some feature')git push origin my-new-feature)This gem have been tested on MRI 1.9.3
Copyright (c) 2009-2012 tokiro.oyama@gmail.com. See LICENSE for details.
FAQs
Unknown package
We found that tree.rb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.