Method: RDoc.home
- Defined in:
- lib/rdoc.rb
.home ⇒ Object
Searches and returns the directory for settings.
-
$HOME/.rdoc
directory, if it exists. -
The
rdoc
directory under the path specified by theXDG_DATA_HOME
environment variable, if it is set. -
$HOME/.local/share/rdoc
directory.
Other than the home directory, the containing directory will be created automatically.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/rdoc.rb', line 132 def self.home rdoc_dir = begin File.('~/.rdoc') rescue ArgumentError end if File.directory?(rdoc_dir) rdoc_dir else require 'fileutils' begin # XDG xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.("~"), '.local', 'share') unless File.exist?(xdg_data_home) FileUtils.mkdir_p xdg_data_home end File.join xdg_data_home, "rdoc" rescue Errno::EACCES end end end |