Skip to content
rubyworks edited this page Sep 13, 2010 · 4 revisions

XDG Base Directory Standard for Ruby

Introduction

XDG provides an easy to use module for utilizing the XDG Base Directory Standard.

If your program utilizes user or system-wide support files (eg. configuration files), you owe it to yourself to checkout the XDG standard.

You can learn more about the standard here.

HOW TO USE

XDG consists of a small set of modules, one for each XDG directory. Each of
these has a small base set of easy to use methods.

    XDG::Config.home
    XDG::Config.dirs
    XDG::Config.find(pattern){ |path| ... }
    XDG::Config.select(pattern){ |path| ... }

    XDG::Data.home
    XDG::Data.dirs
    XDG::Data.find(pattern){ |path| ... }
    XDG::Data.select(pattern){ |path| ... }

    XDG::Cache.home
    XDG::Cache.find(pattern){ |path| ... }
    XDG::Cache.select(pattern){ |path| ... }

XDG can also access these modules via methods.

    XDG.config.home
    XDG.config.dirs
    XDG.config.find(pattern){ |path| ... }
    XDG.config.select(pattern){ |path| ... }

    XDG.data.home
    XDG.data.dirs
    XDG.data.find(pattern){ |path| ... }
    XDG.data.select(pattern){ |path| ... }

    XDG.cache.home
    XDG.cache.find(pattern){ |path| ... }
    XDG.cache.select(pattern){ |path| ... }

If you know XDG these are pretty much self-explanatory. But see the RDocs for specifics.

Extended Functionality

The Ruby XDG module also provides extended functionality not part of the standard specification. These extensions are simply add-on functionality deemed useful, or implementations of proposals being discussed for a possible future version of the standard.

    require 'xdg/extended'

    XDG.config.work
    XDG.cache.work

See the API for the extended.rb, to learn more. Note that the extended modules are subject to great change of change as they are still being designed.

HOW TO INSTALL

Using RubyGems:

  $ sudo gem install xdg

Installing the tarball requires Ruby Setup (see http://proutils.github.com/setup).

  $ tar -xvzf xdg-0.5.2
  $ cd xdg-0.5.2
  $ sudo setup.rb all

COPYRIGHT

Copyright © 2008, 2009 Thomas Sawyer
Distributed under the terms of the LGPL v3 license.
See COPYING file for details.