Class XDG::BaseDir
In: lib/xdg/base_dir.rb
lib/xdg/base_dir/legacy.rb
lib/xdg/base_dir/extended.rb
lib/xdg/base_dir/mixin.rb
Parent: Object

Base directory interface class.

Methods

Included Modules

Enumerable

Classes and Modules

Module XDG::BaseDir::Legacy
Module XDG::BaseDir::Mixin

Constants

DEFAULTS = { 'XDG_DATA_HOME' => ['~/.local/share'], 'XDG_DATA_DIRS' => ['/usr/local/share', datadir], 'XDG_CONFIG_HOME' => ['~/.config'], 'XDG_CONFIG_DIRS' => [File.join(sysconfdir,'xdg'), sysconfdir], 'XDG_CACHE_HOME' => ['~/.cache'], 'XDG_CACHE_DIRS' => ['/tmp']   Standard defaults for locations.

Attributes

subdirectory  [R]  The common subdirectory.

Public Class methods

Shortcut for `BaseDir.new`.

Initialize new instance of BaseDir class.

Public Instance methods

Iterate of each directory.

env()

The environment setting, or it‘s equivalent when the BaseDir is a combination of environment variables.

@return [String] evnironment vsetting

The environment variables being referenced.

@return [Array] list of XDG environment variable names

This is same as environment, but also includes default values.

@return [String] envinronment value.

Find a file or directory. This works just like select except that it returns the first match found.

TODO: It would be more efficient to traverse the dirs and use fnmatch.

Return array of matching files or directories in any of the resource locations, starting with the home directory and searching outward into system directories.

Unlike select, this doesn‘t take a block and each additional glob argument is treated as a logical-or.

  XDG[:DATA].glob("stick/*.rb", "stick/*.yaml")

Returns an unexpanded list of directories.

@return [Array<String>] unexpanded directory list

List of directories as Pathanme objects.

@return [Array<Pathname>] list of directories as Pathname objects

Return array of matching files or directories in any of the resource locations, starting with the home directory and searching outward into system directories.

String parameters are joined into a pathname while Integers and Symbols treated as flags.

For example, the following are equivalent:

  XDG::BaseDir[:DATA,:HOME].select('stick/units', File::FNM_CASEFOLD)

  XDG::BaseDir[:DATA,:HOME].select('stick', 'units', :casefold)

Number of directory paths.

Set subdirectory to be applied to all paths.

Returns a complete list of expanded directories.

@return [Array<String>] expanded directory list

to_ary()

Alias for to_a

The first directory converted to a Pathname object.

@return [Pathname] pathname of first directory

Returns the first directory expanded. Since a environment settings like `*_HOME` will only have one directory entry, this definition of to_s makes utilizing those more convenient.

@return [String] directory

Set subdirectory to be applied to all paths and return `self`.

@return [BaseDir] self

[Validate]