lib/sportdb.rb in sportdb-0.7.1 vs lib/sportdb.rb in sportdb-0.7.2

- old
+ new

@@ -107,9 +107,44 @@ # delete ALL records (use with care!) def self.delete! Deleter.new.run end # method delete! + def self.load_plugins + + @found ||= [] + @loaded ||= {} + @files ||= Gem.find_files( 'sportdb_plugin.rb' ) + + puts "#{@files.size} plugin files found:" + @files.each do |file| + puts " >#{file}<" + end + + ## todo: extract version and name of gem? + puts "normalized/match pattern:" + @files.each do |file| + if file =~ /sportdb-([a-z]+)-(\d\.\d.\d)/ + puts " >#{$1}< | >#{$2}<" + @found << file + else + puts "*** error: ignoring plugin script >#{file}< not matching gem naming pattern" + end + end + + @found.each do |file| + begin + puts "loading plugin script #{file}" + require file + rescue LoadError => e + puts "*** error loading plugin script #{file.inspect}: #{e.message}. skipping..." + end + end + + end + end # module SportDB + +SportDB::load_plugins SportDB.main if __FILE__ == $0 \ No newline at end of file