Class: RuboCop::CacheConfig Private
- Inherits:
-
Object
- Object
- RuboCop::CacheConfig
- Defined in:
- lib/rubocop/cache_config.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This class represents the cache config of the caching RuboCop runs.
Class Method Summary collapse
- .root_dir ⇒ Object private
Class Method Details
.root_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubocop/cache_config.rb', line 7 def self.root_dir root = ENV.fetch('RUBOCOP_CACHE_ROOT', nil) root ||= yield root ||= if ENV.key?('XDG_CACHE_HOME') # Include user ID in the path to make sure the user has write # access. File.join(ENV.fetch('XDG_CACHE_HOME'), Process.uid.to_s) else # On FreeBSD, the /home path is a symbolic link to /usr/home # and the $HOME environment variable returns the /home path. # # As $HOME is a built-in environment variable, FreeBSD users # always get a warning message. # # To avoid raising warn log messages on FreeBSD, we retrieve # the real path of the home folder. File.join(File.realpath(Dir.home), '.cache') end File.join(root, 'rubocop_cache') end |