<img src=“https://codeclimate.com/badge.png” />
<img src=“https://secure.travis-ci.org/evolve75/RubyTree.png” />
RubyTree is a pure Ruby implementation of the generic tree data structure. It provides a node-based model to store keyed node-elements in the tree and provides simple APIs to access, modify and traverse the structure.
RubyTree is node-centric, where individual nodes in the tree are the primary structural elements.
RubyTree mixes in the Enumerable module to allow access to the tree as a standard collection.
RubyTree is an open source project and is hosted at:
rubytree.rubyforge.org and also at github.com/evolve75/RubyTree.
The library is available as a standard gem at rubygems.org/gems/rubytree.
See {file:History.rdoc} for the detailed changelog.
See {file:API-CHANGES.rdoc} for description of potentially backwards incompatible API changes.
{include:file:examples/example_basic.rb}
-
Ruby 1.8.x, 1.9.x, 2.0.x, or 2.1.0x.
-
Run-time Dependencies:
-
JSON for converting to/from the JSON format
-
Development dependencies (not required for installing the gem):
To install the gem, run this command from a terminal/shell:
$ gem install rubytree
This should install the gem file for RubyTree. Note that you might need to have super-user privileges (root/sudo) to successfully install the gem.
RubyTree also be downloaded as a tar/zip file (or as a gem) from:
rubyforge.org/frs/?group_id=1215&release_id=8817
The file-name is one of:
rubytree-<VERSION>.gem - The rubygem rubytree-<VERSION>.tgz - GZipped source files rubytree-<VERSION>.zip - Zipped source files
Download the appropriate file-type for your system.
Extract the archive file (tgz or zip) and run the following command from the top-level source directory:
$ ruby ./setup.rb
You may need administrator/super-user privileges to complete the setup using this method. Note that the source code contains the Rakefile for building using Rake, which might an easier mechanism for building and installing the gem.
The primary class for this implementation is {Tree::TreeNode} See the class documentation for an example of using the library.
If the ri documentation was generated during install, you can use this command at the terminal to view the text mode ri documentation:
$ ri Tree::TreeNode
Documentation for the latest released version is available at:
Documentation for the latest git HEAD is available at:
rdoc.info/projects/evolve75/RubyTree
Note that the documentation is formatted for YARD.
This section is only for modifying RubyTree itself. It is not required for using the library!
You can download the latest released source code as a tar or zip file, as mentioned above in the installation section.
Alternatively, you can checkout the latest commit/revision from the Version Control System. Note that RubyTree’s primary SCM is git and is hosted on github.
For cloning the git repository, use one of the following commands:
$ git clone git://github.com/evolve75/RubyTree.git
or
$ git clone http://github.com/evolve75/RubyTree.git
The git repository is available at: github.com/evolve75/RubyTree
RubyTree uses Bundler to manage its dependencies. This allows for a simplified dependency management, for both run-time as well as during build.
After checking out the source, run:
$ gem install bundler $ bundle install $ rake test $ rake doc:yard $ rake gem:package
These steps will install any missing dependencies, run the tests/specs, generate the documentation, and finally generate the gem file.
Note that the documentation uses YARD, which will be downloaded and installed automatically by Bundler.
A big thanks to the following contributors for helping improve RubyTree:
-
Dirk Breuer for contributing the JSON conversion code.
-
Vincenzo Farruggia for contributing the (sub)tree cloning code.
-
Eric Cline for the Rails JSON encoding fix.
-
Darren Oakley for the tree merge methods.
-
Youssef Rebahi-Gilbert for the code to check duplicate node names in the tree (globally unique names).
-
Paul de Courcel for adding the
postordered_each
method.
{include:file:LICENSE.rdoc}
__ _ _ /__\_ _| |__ _ _| |_ _ __ ___ ___ / \// | | | '_ \| | | | __| '__/ _ \/ _ \ / _ \ |_| | |_) | |_| | |_| | | __/ __/ \/ \_/\__,_|_.__/ \__, |\__|_| \___|\___| |___/
# Local Variables: # mode: rdoc # coding: utf-8-unix # End: