Module: GemHadar::Utils
- Included in:
- GemHadar
- Defined in:
- lib/gem_hadar/utils.rb
Instance Method Summary collapse
-
#xdg_config_filename(name) ⇒ String
The xdg_config_filename method constructs the full path to a configuration file based on the XDG Base Directory specification.
-
#xdg_config_home ⇒ Pathname
The xdg_config_home method determines the path to the XDG configuration directory.
Instance Method Details
#xdg_config_filename(name) ⇒ String
The xdg_config_filename method constructs the full path to a configuration file based on the XDG Base Directory specification.
It first checks if the XDG_CONFIG_HOME environment variable is set and not empty. If it is set, the method joins this directory with the provided filename to form the complete path. If XDG_CONFIG_HOME is not set, it defaults to using the HOME environment variable to construct the path within the standard .config directory.
30 31 32 |
# File 'lib/gem_hadar/utils.rb', line 30 def xdg_config_filename(name) xdg_config_home + name end |
#xdg_config_home ⇒ Pathname
The xdg_config_home method determines the path to the XDG configuration directory.
It first checks if the XDG_CONFIG_HOME environment variable is set and not empty. If it is set, the method returns the value as a Pathname object. If XDG_CONFIG_HOME is not set, it defaults to using the HOME environment variable to construct the path within the standard .config directory.
13 14 15 16 |
# File 'lib/gem_hadar/utils.rb', line 13 def xdg_config_home ENV['XDG_CONFIG_HOME'].full? { Pathname.new(_1) } || Pathname.new(ENV.fetch('HOME')) + '.config' end |