Module: CommandKit::XDG
Overview
Provides access to XDG directories.
~/.config
~/.local/share
~/.cache
Environment Variables
XDG_CONFIG_HOME
- The directory that should contain user-specific configuration. Defaults to~/.config/
.XDG_DATA_HOME
- The directory that should contain user-specific data. Defaults to~/.local/share/
.XDG_CACHE_HOME
- The directory that should contain user-specific cache data. Defaults to~/.cache/
.
Defined Under Namespace
Modules: ClassMethods, ModuleMethods
Instance Attribute Summary collapse
-
#cache_dir ⇒ String
readonly
The
~/.cache/<xdg_namespace>
directory. -
#config_dir ⇒ String
readonly
The
~/.config/<xdg_namespace>
directory. -
#local_share_dir ⇒ String
readonly
The
~/.local/share/<xdg_namespace>
directory.
Attributes included from Env::Home
Attributes included from Env
Attributes included from CommandName
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Object
Initializes #config_dir, #local_share_dir, and #cache_dir.
- #xdg_namespace ⇒ Object
Methods included from ModuleMethods
Methods included from Env::Home::ModuleMethods
Methods included from CommandName::ModuleMethods
Instance Attribute Details
#cache_dir ⇒ String (readonly)
The ~/.cache/<xdg_namespace>
directory.
103 104 105 |
# File 'lib/command_kit/xdg.rb', line 103 def cache_dir @cache_dir end |
#config_dir ⇒ String (readonly)
The ~/.config/<xdg_namespace>
directory.
89 90 91 |
# File 'lib/command_kit/xdg.rb', line 89 def config_dir @config_dir end |
#local_share_dir ⇒ String (readonly)
The ~/.local/share/<xdg_namespace>
directory.
96 97 98 |
# File 'lib/command_kit/xdg.rb', line 96 def local_share_dir @local_share_dir end |
Instance Method Details
#initialize(**kwargs) ⇒ Object
If the $XDG_CONFIG_HOME
env variable is set, then #config_dir will
be initialized to effectively $XDG_CONFIG_HOME/<xdg_namespace>
.
Otherwise #config_dir will be initialized to
~/.config/<xdg_namespace>
.
If the $XDG_DATA_HOME
env variable is set, then #local_share_dir
will be initialized to effectively $XDG_DATA_HOME/<xdg_namespace>
.
Otherwise #local_share_dir will be initialized to
~/.local/share/<xdg_namespace>
.
If the $XDG_CACHE_HOME
env variable is set, then #cache_dir will
be initialized to effectively $XDG_CACHE_HOME/<xdg_namespace>
.
Otherwise #cache_dir will be initialized to
~/.cache/<xdg_namespace>
.
Initializes #config_dir, #local_share_dir, and #cache_dir.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/command_kit/xdg.rb', line 129 def initialize(**kwargs) super(**kwargs) xdg_config_home = env.fetch('XDG_CONFIG_HOME') do File.join(home_dir,'.config') end @config_dir = File.join(xdg_config_home,xdg_namespace) xdg_data_home = env.fetch('XDG_DATA_HOME') do File.join(home_dir,'.local','share') end @local_share_dir = File.join(xdg_data_home,xdg_namespace) xdg_cache_home = env.fetch('XDG_CACHE_HOME') do File.join(home_dir,'.cache') end @cache_dir = File.join(xdg_cache_home,xdg_namespace) end |
#xdg_namespace ⇒ Object
156 157 158 |
# File 'lib/command_kit/xdg.rb', line 156 def xdg_namespace self.class.xdg_namespace end |