Class: ModSpox::BotConfig
- Inherits:
-
Object
- Object
- ModSpox::BotConfig
- Defined in:
- lib/mod_spox/BotConfig.rb
Constant Summary collapse
- @@config =
nil
Class Method Summary collapse
-
.[](name) ⇒ Object
- name
-
Name of the path string you would like Provides access to important path values.
-
.populate ⇒ Object
Populates all important paths.
Class Method Details
.[](name) ⇒ Object
- name
-
Name of the path string you would like
Provides access to important path values
45 46 47 48 49 50 |
# File 'lib/mod_spox/BotConfig.rb', line 45 def self.[](name) BotConfig.populate unless @@config name = name.to_sym unless name.is_a?(Symbol) raise Exceptions::UnknownKey.new("Failed to find given key: #{name}") unless @@config.has_key?(name) return @@config[name] end |
.populate ⇒ Object
Populates all important paths. This does not need to be explicitly called though nothing bad will happen if it is. Keys available are: :basepath => path to gem directory :libpath => path to lib directory :datapath => path to data directory :pluginpath => path to plugin directory :pluginextraspath => path to extra functionality plugins :userpath => path to mod_spox directory in user’s home directory :userpluginpath => path to user’s plugin directory :userconfigpath => path to the user configuration file
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mod_spox/BotConfig.rb', line 18 def self.populate gemname, gem = Gem.source_index.find{|name, spec| spec.name == 'mod_spox' && spec.version.version = $BOTVERSION } if(gem) p = gem.full_gem_path up = $MOD_SPOX_PATH.nil? ? Etc.getpwnam(Etc.getlogin).dir : $MOD_SPOX_PATH @@config = {:basepath => p, :libpath => "#{p}/lib/mod_spox", :datapath => "#{p}/data/mod_spox", :pluginpath => "#{p}/data/mod_spox/plugins", :pluginextraspath => "#{p}/data/mod_spox/extras", :userpath => "#{up}/.mod_spox", :userpluginpath => "#{up}/.mod_spox/plugins", :userconfigpath => "#{up}/.mod_spox/config"} [@@config[:userpath], @@config[:userpluginpath]].each do |path| Dir.mkdir(path) unless File.exists?(path) end else p gem p gemname raise Exceptions::InstallationError.new('Failed to find mod_spox gem') end end |