
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Moved to ---> "rooted".
This gem implements a rooted, ordered tree, but that name is a bit of a mouthful. It is ment to be used as a building block when working with any tree shaped data. For a brief recap of the terminology please see below. Please refer to https://en.wikipedia.org/wiki/Tree_structure for a more in depth description.
A A is the root.
┌────┼──┐ B, C and D are all children of A.
B C D E is a descendant of A.
┌─┼─┐ ┌┴┐ │ A is of degree 3 while C is of degree 2.
E F G H I J F is a leaf.
Add this line to your application's Gemfile:
gem 'rooted_tree'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rooted_tree
Please see the documentation for the complete API.
# Create some nodes
root = RootedTree::Node.new
child_a = RootedTree::Node.new
child_b = RootedTree::Node.new
# Put the two children below the root
root << child_a << child_b
# Look at the result
p root # => RootedTree::Node:0x3fd5d54efda0
# ├─╴RootedTree::Node:0x3fd5d54c3ea8
# └─╴RootedTree::Node:0x3fd5d54ba894
The gem is primarily ment to be extended by other classes. The following example builds a tree of the files in the file system and displays it much like the command line tool tree
.
class FileSystemItem < RootedTree::Node
def display
inspect { |item| item.value }
end
def self.map_to_path path = '.', root: new(path)
# Iterate over all of the files in the directory
Dir[path + '/*'].each do |entry|
# Create a new FileSystemItem for the entry
item = new File.basename(entry)
root << item
# Continue to map the files and directories under
# entry, if it is a directory
map_to_path entry, root: item unless File.file? entry
end
root
end
end
puts FileSystemItem.map_to_path('.').display
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/seblindberg/ruby-rooted_tree.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that rooted_tree 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
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.