lib/rbbt/util/data_module.rb in rbbt-util-1.2.1 vs lib/rbbt/util/data_module.rb in rbbt-util-2.0.1
- old
+ new
@@ -1,26 +1,48 @@
module DataModule
+ def self.rakefiles(sharedir, data_module)
+ Dir.glob(File.join(sharedir, 'install', data_module.to_s, '**','Rakefile')).collect{|f| File.expand_path f}
+ end
+
attr_accessor :sharedir, :rakefile, :pkg_module
- def self.extended(base)
- if defined? base::PKG and base::PKG
- base.pkg_module = base::PKG
+ def self.extended(data_module)
+ if defined? data_module::PKG and data_module::PKG
+ data_module.pkg_module = data_module::PKG
else
- base.pkg_module = Rbbt
+ data_module.pkg_module = Rbbt
end
- base.sharedir = PKGData.get_caller_sharedir
+ data_module.sharedir = PKGData.get_caller_sharedir
- Dir.glob(File.join(base.sharedir, 'install', base.to_s, '**','Rakefile')).each do |rakefile|
+ install_dir = File.join(data_module.sharedir, 'install')
+ rake_sharedir = File.join(data_module.sharedir, 'install')
+
+ rakefiles(data_module.sharedir, data_module).each do |rakefile|
+ rakefile_dir = File.dirname(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')}\/?/,'')
+ file_path = Misc.path_relative_to(File.join(File.dirname(rakefile), file), rakefile_dir)
+ get = :Rakefile
+ subdir = Misc.path_relative_to(File.dirname(rakefile), install_dir)
+ namespace = data_module.to_s.gsub('/', '::')
+
+ data_module.pkg_module.claim file_path, get, subdir, namespace, rake_sharedir
end
end
end
+ def files
+ DataModule.rakefiles(sharedir, self).collect do |rakefile|
+ RakeHelper.files(rakefile).collect
+ end.flatten
+ end
+
+ def datadir
+ File.join(pkg_module.datadir, self.to_s)
+ end
+
module WithKey
def klass=(klass)
@klass = klass
end
@@ -66,8 +88,6 @@
Log.debug $!.message
Log.debug $!.backtrace * "\n"
old_method_missing name, *args, &block
end
end
-
-
end