Skip to content

Commit

Permalink
Fix plugin config file loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgreenlee committed Sep 3, 2011
1 parent 516c29e commit 4e5f392
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion campfire/polling_bot/plugin.rb
Expand Up @@ -17,7 +17,7 @@ def initialize
gsub(/([[:lower:]\d])([[:upper:]])/,'\1_\2').
tr("-", "_").
downcase
filepath = File.dirname(__FILE__) + "/plugins/config/#{name}.yml"
filepath = File.join(self.class.directory, "#{name}.yml")
if File.exists?(filepath)
self.config = YAML.load_file(filepath)
else
Expand All @@ -27,6 +27,9 @@ def initialize

# keep track of subclasses
def self.inherited(klass)
# save the plugin's directory
filepath = caller[0].split(':')[0]
klass.directory = File.dirname(caller[0].split(':')[0])
super if defined? super
ensure
( @subclasses ||= [] ).push(klass).uniq!
Expand All @@ -39,6 +42,14 @@ def self.subclasses
end
end

def self.directory=(dir)
@directory = dir
end

def self.directory
@directory
end

# bot accessor
def self.bot
@@bot
Expand Down

0 comments on commit 4e5f392

Please sign in to comment.