From 77adfe9d6fb72bc5eccfedc40e93850d997a5c2b Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sun, 4 Sep 2011 04:50:38 +0200 Subject: [PATCH] config & constants: Use constants for default locations. --- qasim/config.rb | 21 ++------------------- qasim/constants.rb | 9 ++++++++- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/qasim/config.rb b/qasim/config.rb index 81dd072..b25d8f7 100644 --- a/qasim/config.rb +++ b/qasim/config.rb @@ -20,27 +20,10 @@ module Qasim def initialize - user = if ENV['USER'] then - ENV['USER'] - else - raise "Environment variable 'USER' is missing!" - end - home_dir = if ENV['HOME'] then - ENV['HOME'] - else - "/home/" + user - end + @mnt_dir = File.join ENV['HOME'], "mnt" - xdg_dir = if ENV['XDG_CONFIG_HOME'] then - ENV['XDG_CONFIG_HOME'] - else - home_dir + '/.config' - end - - @mnt_dir = File.join home_dir, "mnt" - - @config_dir = xdg_dir + '/sshfs-mapper' + @config_dir = APP_CONFIG_DIR @config_file = nil @maps = [] @initialize_enable = false diff --git a/qasim/constants.rb b/qasim/constants.rb index 0ffc237..fd21c64 100644 --- a/qasim/constants.rb +++ b/qasim/constants.rb @@ -1,6 +1,13 @@ module Qasim APP_ICON_PATH = File.join QASIM_INCLUDE_DIR, "icons" - APP_SYSCONFIG_DIR = "/etc/qasim/maps.d" APP_NAME = "Qasim" APP_VERSION = "0.1" + + APP_SYSCONFIG_DIR = "/etc/qasim/maps.d" + + APP_CONFIG_DIR = if ENV['XDG_CONFIG_HOME'] then + File.join ENV['XDG_CONFIG_HOME'], 'qasim' + else + File.join ENV['HOME'], '.config', 'qasim' + end end