0.0
No commit activity in last 3 years
No release in over 3 years
Transforms a file system in a tree with content and meta data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9
>= 0
 Project Readme

document_tree¶ ↑

DocumentTree is a gem that can read out a simple file tree. It can be used to generate a tree with documentation in Ruby on Rails, so that pages don’t have to be in a database.

Usage¶ ↑

You must have a folder that will be read some where. For example the following example will generate a tree.

  • section (folder)

    • meta.txt (file)

    • othersection (folder)

      • somefile.txt (file)

If you now invoke DocumentTree.root.name the meta.txt is read for a real name.

Meta data¶ ↑

All meta data is YAML format. Normal files have meta data on top of the file, splitted by line. Directories have a meta data on top of meta.txt.

Format folder meta data¶ ↑

The meta data for a folder is read by reading the meta.txt of it’s children. For example, meta.txt has the following content, the first line is the YAML meta data, the rest is content.

name: DocumentTree documentation

Here comes the text, maybe formatted in some way.
Tralala.

Now the following code:

node = DocumentTree.root 
node.name
# => DocumentTree.documentation
node.content
# => Here comes the text, maybe formatted in some way.\nTralala.
node.raw_name
# => section

Finding a node¶ ↑

You can search for a node by doing

DocumentTree.root.find_node("hisrawname")

Returning all nodes¶ ↑

DocumentTree.root.all_nodes

Copyright © 2010 Jaap van der Meer. See LICENSE for details.