Class: DirCat::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/dircat/config.rb

Class Method Summary collapse

Class Method Details

.user_config_dirObject

user config dir normally is

~/.dircat


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dircat/config.rb', line 7

def self.user_config_dir
  # find directory where to store catalog data
  # depends on OS
  user_home_dir = ENV['HOME'] || ENV['APPDATA']
  if user_home_dir
    if RUBY_PLATFORM =~ /linux/
      config_dir = File.expand_path(File.join(user_home_dir, "." + DirCat::NAME))
    else
      config_dir = File.expand_path(File.join(user_home_dir, DirCat::NAME))
    end
    Dir.mkdir(config_dir) unless File.directory?(config_dir)
    config_dir
  else
    File.join(home_dir, "config")
  end
end