Folio
Folio is a better way to access the filesystem in your Ruby
programs. It works by emulating the behavior of a command shell. So just
as you 'cd' up and down the file hierarchy at a shell prompt,
so do you 'cd' using a Folio Shell object.
Are you having an "Ah ha" moment now?
Using Folio is just like using the familiar command shell. So there is no learning curve, no confusion about which module provides what service. And becuase it is an object, it can be passed around an reused.
Working with the file system in Ruby just go a whole lot, well... a whole lot more "Ruby"!
Fantastic File I/O
Folio is a "better way" to access the filesystem in your Ruby
programs. It works by emulating the behavior of a command shell. So just
as you would cd up and down the file hierarchy at a shell prompt,
you do the same against a Folio Prompt object.
In addition, Folio encapsulates all the common File System object types, providing a more OOP means of working with them. For instance, Folio::Link represents a link on the file system, and just as the link references another file, so de the Folio::Link object deletgate to another Folio file object.
To learn more about how to use Folio, click the Usage tab above, or for even more gritty details have a look at the API documentation.
Installation
To install -- you know the Gem drill.
$ gem install folio
And you may also know the Setup drill.
$ tar -xvzf folio-0.1.0.tgz $ cd folio-0.1.0.tgz $ sudo setup.rb
This later procedure requires Ruby Setup.
Very Easy To Use
Since this is such an early release the API is still subject to change. But the basic idea remains the same:
require 'folio'
# get a folio prompt on the current directory (Dir.pwd).
fs = Folio::Shell.new
# return a list of directory's entries as strings.
fs.ls
# return a list of directories as Directory objects.
fs.directories
# return a list of regular files as Document objects.
fs.documents
# Change down to the foo directory.
fs.cd('foo')
# return a list of all entries as File objects.
p fs.files
We can use the file() method to access a file
and work with it as an object.
# get a hold on foo.txt file.
file = fs.file('foo.txt')
# read it's contents
text = file.read
# examine foo.txt's creation timestamp
file.ctime
Other Resources
Rio is another library in the same spirit as Folio. Although it has a different desgin philosophy than Folio, it looks like a well written library with good documentation.