rubyworks / xdg

XDG Base Directory Standard Library for Ruby

Home Page:http://rubyworks.github.com/xdg/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Concept for potentially better interface

trans opened this issue · comments

Where as currently we have a partial method/constant interface, e.g. XDG::Config.home or XDG.config.home. It is possible to use a complete constant and make it act both like an string/array and a pathname.

XDG::CONFIG::HOME  => "~/.config"
XDG::CONFIG::DIRS  => ["/etc/xdg", "/etc"]

But still have a file based set of methods too:

XDG::CONFIG::DIRS.find(pattern){ |f| .... }
XDG::CONFIG::DIRS.glob(pattern){ |f| .... }

And to include both home and dirs:

XDG::CONFIG.find(pattern){ |f| .... }
XDG::CONFIG.glob(pattern){ |f| .... }

(Might use a different name for #find since that's used by Enumerable already, but not sure what that might be.)

Hell, technically they could just be called:

XDG_CONFIG
XDG_CONFIG_HOME
XDG_CONFIG_DIRS

Then they would look just like the environment variables.