{"id":15903698,"url":"https://github.com/evolve75/rubytree","last_synced_at":"2026-02-07T01:20:59.466Z","repository":{"id":37381804,"uuid":"459782","full_name":"evolve75/RubyTree","owner":"evolve75","description":"A General Purpose Tree Data Structure for Ruby","archived":false,"fork":false,"pushed_at":"2024-12-24T06:48:18.000Z","size":1131,"stargazers_count":372,"open_issues_count":5,"forks_count":91,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-14T22:04:23.468Z","etag":null,"topics":["data-structures","rt-gem","ruby","traversal","tree"],"latest_commit_sha":null,"homepage":"http://rubytree.anupamsg.me","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evolve75.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2010-01-05T19:55:35.000Z","updated_at":"2025-03-23T18:19:11.000Z","dependencies_parsed_at":"2024-01-13T03:01:14.807Z","dependency_job_id":"1b5e4c29-03e5-48dd-a547-555d367e0838","html_url":"https://github.com/evolve75/RubyTree","commit_stats":{"total_commits":614,"total_committers":29,"mean_commits":21.17241379310345,"dds":0.3224755700325733,"last_synced_commit":"6b92eced42132091fb5d1097e06c798d6da06991"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolve75%2FRubyTree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolve75%2FRubyTree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolve75%2FRubyTree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolve75%2FRubyTree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evolve75","download_url":"https://codeload.github.com/evolve75/RubyTree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059507,"owners_count":22007768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","rt-gem","ruby","traversal","tree"],"created_at":"2024-10-06T12:03:49.407Z","updated_at":"2026-02-07T01:20:59.397Z","avatar_url":"https://github.com/evolve75.png","language":"Ruby","readme":"# **RubyTree** #\n\n[![Gem Version](https://badge.fury.io/rb/rubytree.png)](http://badge.fury.io/rb/rubytree)\n![Build State](https://github.com/evolve75/rubytree/actions/workflows/ruby.yml/badge.svg)\n[![Code Climate](https://codeclimate.com/github/evolve75/RubyTree.png)](https://codeclimate.com/github/evolve75/RubyTree)\n[![Coverage Status](https://coveralls.io/repos/evolve75/RubyTree/badge.png)](https://coveralls.io/r/evolve75/RubyTree)\n\n        __       _           _\n       /__\\_   _| |__  _   _| |_ _ __ ___  ___\n      / \\// | | | '_ \\| | | | __| '__/ _ \\/ _ \\\n     / _  \\ |_| | |_) | |_| | |_| | |  __/  __/\n     \\/ \\_/\\__,_|_.__/ \\__, |\\__|_|  \\___|\\___|\n                      |___/\n\n## DESCRIPTION: ##\n\n**RubyTree** is a pure Ruby implementation of the generic\n[tree data structure][tree_data_structure]. It provides a node-based model to\nstore named nodes in the tree, and provides simple APIs to access, modify and\ntraverse the structure.\n\nThe implementation is *node-centric*, where individual nodes in the tree are the\nprimary structural elements. All common tree-traversal methods ([pre-order][],\n[post-order][], and [breadth-first][]) are supported.\n\nThe library mixes in the [Enumerable][] and [Comparable][] modules to allow\naccess to the tree as a standard collection (iteration, comparison, etc.).\n\nA [Binary tree][] is also provided, which provides the [in-order][] traversal in\naddition to the other methods.\n\n**RubyTree** supports importing from, and exporting to [JSON][], and also\nsupports the Ruby's standard object [marshaling][].\n\nThis is a [BSD licensed][BSD] open source project, and is hosted at\n[github.com/evolve75/RubyTree][rt@github], and is available as a standard gem\nfrom [rubygems.org/gems/rubytree][rt_gem].\n\nThe home page for **RubyTree** is at [rubytree.anupamsg.me][rt_site].\n\n## WHAT'S NEW: ##\n\nSee [History](./History.md) for the detailed Changelog.\n\nSee [API-CHANGES](./API-CHANGES.md) for the detailed description of\nAPI level changes.\n\n## GETTING STARTED: ##\n\nThis is a basic usage example of the library to create and manipulate a tree.\nSee the [API][rt_doc] documentation for more details.\n\n```ruby\n#!/usr/bin/env ruby\n#\n# example_basic.rb:: Basic usage of the tree library.\n#\n# Copyright (C) 2013-2022 Anupam Sengupta \u003canupamsg@gmail.com\u003e\n#\n# The following example implements this tree structure:\n#\n#                    +------------+\n#                    |    ROOT    |\n#                    +-----+------+\n#            +-------------+------------+\n#            |                          |\n#    +-------+-------+          +-------+-------+\n#    |  CHILD 1      |          |  CHILD 2      |\n#    +-------+-------+          +---------------+\n#            |\n#            |\n#    +-------+-------+\n#    | GRANDCHILD 1  |\n#    +---------------+\n\n# ..... Example starts.\nrequire 'tree'                 # Load the library\n\n# ..... Create the root node first.\n# ..... Note that every node has a name and an optional content payload.\nroot_node = Tree::TreeNode.new(\"ROOT\", \"Root Content\")\nroot_node.print_tree\n\n# ..... Now insert the child nodes.\n#       Note that you can \"chain\" the child insertions to any depth.\nroot_node \u003c\u003c Tree::TreeNode.new(\"CHILD1\", \"Child1 Content\") \u003c\u003c Tree::TreeNode.new(\"GRANDCHILD1\", \"GrandChild1 Content\")\nroot_node \u003c\u003c Tree::TreeNode.new(\"CHILD2\", \"Child2 Content\")\n\n# ..... Lets print the representation to stdout.\n# ..... This is primarily used for debugging purposes.\nroot_node.print_tree\n\n# ..... Lets directly access children and grandchildren of the root.\n# ..... The can be \"chained\" for a given path to any depth.\nchild1       = root_node[\"CHILD1\"]\ngrand_child1 = root_node[\"CHILD1\"][\"GRANDCHILD1\"]\n\n# ..... Now retrieve siblings of the current node as an array.\nsiblings_of_child1 = child1.siblings\n\n# ..... Retrieve immediate children of the root node as an array.\nchildren_of_root = root_node.children\n\n# ..... Retrieve the parent of a node.\nparent = child1.parent\n\n# ..... This is a depth-first and L-to-R pre-ordered traversal.\nroot_node.each { |node| node.content.reverse }\n\n# ..... Remove a child node from the root node.\nroot_node.remove!(child1)\n\n# .... Many more methods are available. Check out the documentation!\n```\n\nThis example can also be found at\n[examples/example_basic.rb](examples/example_basic.rb).\n\n## REQUIREMENTS: ##\n\n* [Ruby][] 2.7.x and above.\n\n\n* Run-time Dependencies:\n\n    * [JSON][] for converting to/from the JSON format\n\n\n* Development dependencies (not required for installing the gem):\n\n    * [Bundler][] for creating the stable build environment\n    * [Rake][] for building the package\n    * [Yard][] for the documentation\n    * [RSpec][] for additional Ruby Spec test files\n    * [Rubocop][] for linting the code\n\n## INSTALL: ##\n\nTo install the [gem][rt_gem], run this command from a terminal/shell:\n\n    $ gem install rubytree\n\nThis should install the gem file for **RubyTree**. Note that you might need to\nhave super-user privileges (root/sudo) to successfully install the gem.\n\n## DOCUMENTATION: ##\n\nThe primary class **RubyTree** is [Tree::TreeNode][TreeNode]. See the class\ndocumentation for an example of using the library.\n\nIf the *ri* documentation was generated during install, you can use this\ncommand at the terminal to view the text mode ri documentation:\n\n    $ ri Tree::TreeNode\n\nDocumentation for the latest released version is available at:\n\n[rubytree.anupamsg.me/rdoc][rt_doc]\n\nDocumentation for the latest git HEAD is available at:\n\n[rdoc.info/projects/evolve75/RubyTree][rt_doc@head]\n\nNote that the documentation is formatted using [Yard][].\n\n## DEVELOPERS: ##\n\nThis section is only for modifying **RubyTree** itself. It is not required for\nusing the library!\n\nYou can download the latest released source code as a tar or zip file, as\nmentioned above in the installation section.\n\nAlternatively, you can checkout the latest commit/revision from the Version\nControl System. Note that **RubyTree**'s primary [SCM][] is [git][] and is\nhosted on [github.com][rt@github].\n\n### Using the git Repository ###\n\nThe git repository is available at [github.com/evolve75/RubyTree][rt@github].\n\nFor cloning the git repository, use one of the following commands:\n\n    $ git clone git://github.com/evolve75/RubyTree.git    # using ssh\n\nor\n\n    $ git clone https://github.com/evolve75/RubyTree.git  # using https\n\n### Setting up the Development Environment ###\n\n**RubyTree** uses [Bundler][] to manage its dependencies. This allows for a\nsimplified dependency management, for both run-time as well as during build.\n\nAfter checking out the source, run:\n\n    $ gem install bundler\n    $ bundle install\n    $ bundle exec rake test:all\n    $ bundle exec rake doc:yard\n    $ bundle exec rake gem:package\n\nThese steps will install any missing dependencies, run the tests/specs,\ngenerate the documentation, and finally generate the gem file.\n\nNote that the documentation uses [Yard][], which will be\ndownloaded and installed automatically by [Bundler][].\n\n## ACKNOWLEDGMENTS: ##\n\nA big thanks to the following contributors for helping improve **RubyTree**:\n\n1. Dirk Breuer for contributing the JSON conversion code.\n2. Vincenzo Farruggia for contributing the (sub)tree cloning code.\n3. [Eric Cline](https://github.com/escline) for the Rails JSON encoding fix.\n4. [Darren Oakley](https://github.com/dazoakley) for the tree merge methods.\n5. [Youssef Rebahi-Gilbert](https://github.com/ysf) for the code to check\n   duplicate node names in the tree (globally unique names).\n6. [Paul de Courcel](https://github.com/pdecourcel) for adding the\n   `postordered_each` method.\n7. [Jen Hamon](http://www.github.com/jhamon) for adding the `from_hash` method.\n8. [Evan Sharp](https://github.com/packetmonkey) for adding the `rename` and\n   `rename_child` methods.\n9. [Aidan Steele](https://github.com/aidansteele) for performance improvements\n   to `is_root?` and `node_depth`.\n10. [Marco Ziccadi](https://github.com/MZic) for adding the `path_as_string` and\n    `path_as_array` methods.\n11. [John Mortlock](https://github.com/jmortlock) for significant modernization\n    of the library code and addition of Github `workflows`.\n12. [Hermann Mayer](https://github.com/jack12816) for adding support for\n    specialized tree nodes (sub-classes of `Tree::TreeNode`).\n13. [Jakub Pavlik](https://github.com/igneus) for fixing the creation of\n    detached copies of unclonable objects such as `:symbol`, `true|false`, etc.\n14. [bghalami-rc](https://github.com/bghalami-rc) for updating the guard clause\n    in the `from_hash` method.\n\n\n## LICENSE: ##\n\n**RubyTree** is licensed under the terms of the [BSD][] license. See\n[LICENSE.md](./LICENSE.md) for details.\n\n\n[BSD]:                  http://opensource.org/licenses/bsd-license.php \"BSD License\"\n[Binary tree]:          http://en.wikipedia.org/wiki/Binary_tree \"Binary Tree Data Structure\"\n[Bundler]:              http://bundler.io \"Bundler\"\n[Comparable]:           http://ruby-doc.org/core/Comparable.html \"Comparable mix-in\"\n[Enumerable]:           http://ruby-doc.org/core/Enumerable.html \"Enumerable mix-in\"\n[JSON]:                 https://rubygems.org/gems/json \"JSON\"\n[Rake]:                 https://rubygems.org/gems/rake \"Rake\"\n[Ruby]:                 http://www.ruby-lang.org \"Ruby Programming Language\"\n[SCM]:                  http://en.wikipedia.org/wiki/Source_Code_Management \"Source Code Management\"\n[Yard]:                 http://yardoc.org \"Yard Document Generator\"\n[breadth-first]:        http://en.wikipedia.org/wiki/Breadth-first_search \"Breadth-first (level-first) Traversal\"\n[git]:                  http://git-scm.com \"Git SCM\"\n[in-order]:             http://en.wikipedia.org/wiki/Tree_traversal#In-order \"In-order (symmetric) Traversal\"\n[marshaling]:           http://ruby-doc.org/core/Marshal.html \"Marshaling in Ruby\"\n[post-order]:           http://en.wikipedia.org/wiki/Tree_traversal#Post-order \"Post-ordered Traversal\"\n[pre-order]:            http://en.wikipedia.org/wiki/Tree_traversal#Pre-order \"Pre-ordered Traversal\"\n[rt@github]:            http://github.com/evolve75/RubyTree \"RubyTree Project Page on Github\"\n[rt_doc@head]:          http://rdoc.info/projects/evolve75/RubyTree \"RubyTree Documentation for VCS Head\"\n[rt_doc]:               http://rubytree.anupamsg.me/rdoc \"RubyTree Documentation\"\n[rt_gem]:               http://rubygems.org/gems/rubytree \"RubyTree Gem\"\n[rt_site]:              http://rubytree.anupamsg.me \"RubyTree Site\"\n[tree_data_structure]:  http://en.wikipedia.org/wiki/Tree_data_structure \"Tree Data Structure\"\n[RSpec]:                https://relishapp.com/rspec/\n[Rubocop]:              https://rubocop.org/\n\n[TreeNode]:             rdoc-ref:Tree::TreeNode\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolve75%2Frubytree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevolve75%2Frubytree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolve75%2Frubytree/lists"}