6 # first try for the default path to the data dir
7 defaultdatadir = File.expand_path(File.dirname($0) + '/../data/rbot')
8 defaultcoredir = File.expand_path(File.dirname($0) + '/../lib/rbot/core')
10 if File.directory? defaultdatadir
11 @@datadir = defaultdatadir
14 if File.directory? defaultcoredir
15 @@coredir = defaultcoredir
18 # setup pkg-based configuration - i.e. where were we installed to, where
19 # are our data files, etc.
20 if @@datadir.nil? or @@coredir.nil?
22 debug "trying to load rubygems"
24 debug "loaded rubygems, looking for rbot-#$version"
25 if $version =~ /(.*)-svn\Z/
30 gemname, gem = Gem.source_index.find{|name, spec| spec.name == 'rbot' && spec.version.version == version}
31 debug "got gem #{gem}"
32 if gem && path = gem.full_gem_path
33 debug "installed via rubygems to #{path}"
34 @@datadir = "#{path}/data/rbot"
35 @@coredir = "#{path}/lib/rbot/core"
37 debug "not installed via rubygems"
39 rescue LoadError,NameError,NoMethodError
40 debug "no rubygems installed"
44 if @@datadir.nil? or @@coredir.nil?
46 require 'rbot/pkgconfig'
47 @@datadir = PKGConfig::DATADIR
48 @@coredir = PKGConfig::COREDIR
50 error "fatal - no way to determine data or core dir"