Redwood: Ruby Trees

Redwood is my newest project: a simple implementation of a tree data structure in pure Ruby. It provides a few things:

  • The redwood command-line tool: a Ruby hack/rewrite of the Unix tree program.
  • A Module providing tree-like methods for your objects.
  • A Redwood::Node class as a basic implementation of tree creation.
  • A Redwood::FileNode class for representing directories in a tree-like way.

gem install redwood to get started.

Learn about, enjoy, and fork the redwood project over at GitHub. For help with the redwood CLI, read the redwood(1) manpage.

My favorite thing about Redwood is that you get the awesome tree view for all of the tree objects that mix-in Redwood:

Redwood
|-- bin
|   `-- redwood
|-- Gemfile
|-- lib
|   |-- redwood
|   |   |-- filenode.rb
|   |   `-- node.rb
|   `-- redwood.rb
|-- LICENSE
|-- pkg
|   `-- redwood-0.0.1.gem
|-- Rakefile
|-- README.md
|-- redwood.gemspec
`-- test
    |-- helper.rb
    `-- test_redwood.rb

Redwood was created mostly to facilitate this kind of thing, and as a bit of a brain-teaser. The redwood CLI is, honestly, totally inferior to the original tree (written in C). I was getting frustrated working on Prism, and I created Redwood to get my mind wrapped around the concept of tree structures. While there are several implementations of tree data-structures in Ruby, I wasn’t really impressed with any of their APIs. And none of them created the tree-view that you get with the Redwood#view method.

Redwood began life as a thought-experiment and I hope you are able to use it whenever you need something resembling a tree.

  1. bluray3d reblogged this from mwunsch
  2. ted-is-a-nerd reblogged this from mwunsch and added:
    He’s on fire!
  3. mwunsch posted this