lib/rbbt/util/data_module.rb in rbbt-util-1.1.0 vs lib/rbbt/util/data_module.rb in rbbt-util-1.2.1

- old
+ new

@@ -1,50 +1,24 @@ module DataModule + attr_accessor :sharedir, :rakefile, :pkg_module def self.extended(base) if defined? base::PKG and base::PKG base.pkg_module = base::PKG else base.pkg_module = Rbbt end base.sharedir = PKGData.get_caller_sharedir - end - - def pkg_module - @pkg_module - end - - def pkg_module=(pkg_module) - @pkg_module = pkg_module - end - - def sharedir - @sharedir - end - - def sharedir=(sharedir) - @sharedir = sharedir - end - - alias old_method_missing method_missing - def method_missing(name, *args, &block) - if args.any? - filename = File.join(self.to_s, args.first, name.to_s) - else - filename = File.join(self.to_s, name.to_s) + + Dir.glob(File.join(base.sharedir, 'install', base.to_s, '**','Rakefile')).each do |rakefile| + RakeHelper.files(rakefile).each do |file| + base.pkg_module.claim file, + rakefile.sub(/^#{Regexp.quote File.join(base.sharedir)}\/?/,''), + File.dirname(rakefile).sub(/^#{Regexp.quote File.join(base.sharedir, 'install')}\/?/,'') + end end - - begin - pkg_module.add_datafiles filename => ['', self.to_s, sharedir] - rescue - Log.debug $!.message - Log.debug $!.backtrace * "\n" - old_method_missing name, *args, &block - end - - pkg_module.find_datafile filename end module WithKey def klass=(klass) @klass = klass @@ -77,6 +51,23 @@ o.extend WithKey o.klass = self o.key = key o end + + alias old_method_missing method_missing + def method_missing(name, *args, &block) + begin + if args.any? + pkg_module.files[self.to_s][args.first][name] + else + pkg_module.files[self.to_s][name] + end + rescue + Log.debug $!.message + Log.debug $!.backtrace * "\n" + old_method_missing name, *args, &block + end + end + + end