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.



Copyright ©2008 TigerOps / Thomas Sawyer

Folio is distributed under the terms of the GPLv3.

THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.