Directory structure of rubytree

Hi, I am working on a project in which if we click on to the browse button then it should show only the directories,which is possible using the rubytree that is a gem.I have require that gem too but i am not getting the graphical representation of the directories structure where in we can save or retrive the documents.If anybody Knows about this plz reply me as soon as possible. It willbe well and good if i get a practical examlpe or code for this. Thank you in advance.Hope to get the reply fast.thanxs.

Rutuja Dive wrote:

Hi, I am working on a project in which if we click on to the browse button then it should show only the directories,which is possible using the rubytree that is a gem.I have require that gem too but i am not getting the graphical representation of the directories structure where in we can save or retrive the documents.If anybody Knows about this plz reply me as soon as possible. It willbe well and good if i get a practical examlpe or code for this. Thank you in advance.Hope to get the reply fast.thanxs.

Below code can be used to convert directory structure in xml.

require 'rubygems' require 'rexml/document'

class DirectoryStructure @@excludes = ["..","."] @@doc = REXML::Document.new %{ <?xml version="1.0" encoding="UTF-8" ?> }

def self.traverse_directory(root_path)

  #traverse initial directory structure   folder = @@doc.add_element( 'myroot',{'id' => root_path} )

  #call loop_path with root_path and parent_node   loop_path(root_path,folder)   #create xml file    open( "final_directory_structure.xml", "w" ) do |f|     f.puts @@doc   end

end

def self.loop_path(path,parent_node)

dir_entries= Dir.entries(path)

# don't need '.','..' dir_entries = dir_entries-['.','..']

dir_entries.each do | entry |

# check if directory or file if File.directory?(path+"/"+entry)

   #Folders Loop -------------------------------------------------    #Gets the directories of the current node.    #It changes for each recursive call    folder = parent_node.add_element( 'folder' ,{'label' =>entry ,'file_path' => path+"/"+entry } )    loop_path( path+"/"+entry, folder ) else    #Files Loop ------------------------------------------------------    file = parent_node.add_element( 'file' ,{'label' =>entry ,'file_path' => path+"/"+entry } )

end

end

end

#first call to traverse directory self.traverse_directory("Authentication/Authentication")

end