lib/AppConfig.rb in taskjuggler-0.0.3 vs lib/AppConfig.rb in taskjuggler-0.0.4
- old
+ new
@@ -1,18 +1,19 @@
#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = AppConfig.rb -- The TaskJuggler III Project Management Software
#
-# Copyright (c) 2006, 2007, 2008, 2009 by Chris Schlaeger <cs@kde.org>
+# Copyright (c) 2006, 2007, 2008, 2009, 2010 by Chris Schlaeger <cs@kde.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
require 'rbconfig'
+require 'rbconfig/datadir'
# This class provides central management of configuration data to an
# application. It stores the version number, the name of the application and
# the suite it belongs to. It also holds copyright and license information.
# These infos have to be set in the main module of the application right after
@@ -21,10 +22,11 @@
class AppConfig
def initialize
@@version = '0.0.0'
@@packageName = 'unnamed'
+ @@softwareName = 'unnamed'
@@packageInfo = 'no info'
@@appName = 'unnamed'
@@authors = []
@@copyright = []
@@contact = 'not specified'
@@ -45,10 +47,18 @@
def AppConfig.packageName
@@packageName
end
+ def AppConfig.softwareName=(name)
+ @@softwareName = name
+ end
+
+ def AppConfig.softwareName
+ @@softwareName
+ end
+
def AppConfig.packageInfo=(info)
@@packageInfo = info
end
def AppConfig.packageInfo
@@ -94,24 +104,27 @@
def AppConfig.license
@@license
end
def AppConfig.dataDirs(baseDir = 'data')
- siteLibDir = ::Config::CONFIG['sitelibdir']
- siteBaseDir, rubyVersionDir = siteLibDir.scan(/(.*\/)(.*)/)[0]
+ rubyLibDir = RbConfig::CONFIG['rubylibdir']
+ rubyBaseDir, versionDir = rubyLibDir.scan(/(.*\/)(.*)/)[0]
+
dirs = []
- # This is for the development version. We assume that we run the app
- # from the source base directory.
- dirs << "#{baseDir}/"
- # Or from the lib directory.
- dirs << "../#{baseDir}/"
+ if ENV['TASKJUGGLER_DATA_PATH']
+ dirs << ENV['TASKJUGGLER_DATA_PATH'] + "/#{baseDir}/"
+ end
# This hopefully works for all setups. Otherwise we have to add more
# alternative pathes.
- dirs << siteBaseDir + "gems/" + rubyVersionDir + '/gems/' \
+ # This one is for RPM based distros like Novell
+ dirs << rubyBaseDir + "gems/" + versionDir + '/gems/' \
+ @@packageName + '-' + @@version + "/#{baseDir}/"
+ # This one is for Debian based distros
+ dirs << rubyLibDir + '/gems/' \
+ + @@packageName + '-' + @@version + "/#{baseDir}/"
# Remove non-existing directories from the list again
dirs.delete_if do |dir|
- !File.exists?(dir)
+ !File.exists?(dir.untaint)
end
dirs
end
def AppConfig.dataFiles(fileName)