5 # first try for the default path to the data dir
6 defaultdir = File.expand_path(File.dirname($0) + '/../data')
8 if File.directory? "#{defaultdir}/rbot"
9 @@datadir = "#{defaultdir}/rbot"
12 # setup pkg-based configuration - i.e. where were we installed to, where
13 # are our data files, etc.
16 debug "trying to load rubygems"
18 debug "loaded rubygems, looking for rbot-#$version"
19 if $version =~ /(.*)-svn\Z/
24 gemname, gem = Gem.source_index.find{|name, spec| spec.name == 'rbot' && spec.version.version == version}
25 debug "got gem #{gem}"
26 if gem && path = gem.full_gem_path
27 debug "installed via rubygems to #{path}"
28 @@datadir = "#{path}/data/rbot"
30 debug "not installed via rubygems"
32 rescue LoadError,NameError,NoMethodError
33 debug "no rubygems installed"
39 require 'rbot/pkgconfig'
40 @@datadir = PKGConfig::DATADIR
42 puts "fatal - no way to determine data dir"