Forum: Ruby Rake project structure,? good?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Peter P. (Guest)
on 2009-01-17 07:22
So more Raking - wanting to divide up projects in subdirs into
sandbox directories but also have parent rakefile actually include their
"children" into the dependency graph to be more efficient and accurate.
and yet allow each "sandbox" rakefile.

I have come up with the below and want to know if this is a 'best' way
or if people see it as silly and there is a more "normal" method
(I am a recent Ruby/Rake newbee)

pardon tabs expand big here
##### a 'parent' rakefile

task :default => [:test]

# load all rakefiles for sub projects, create tasks
# and dependecy graph

rakefiles = FileList.new(File.expand_path('**/rakefile.rb'))
myDir = pwd # save here
rakefiles.each do |rakefile|
  cd File.dirname(rakefile)
  load 'rakefile.rb'
end
cd myDir # restore here

# :subtest is in a subdirectory module
task :test => [:subtest] do |t|
   p "root test"
end


##### rakefile in a subdirectory

# subdir/rakefile

# while "file" defacto anonymous module
Module.new do
public # defacto private nut public for internal blocks

  # variables are "instance" variables
  @me = object_id   # unique for this Module and small
  def doIt
    puts "doing it in #{@me}"
  end
  module_function :doIt # is there an easier way to do this?

  namespace @me do # unique (private) namespace for this module
    # private task definitions for this module
    task :subtest do |t|
      doIt
      puts "submake subtest in #{@me}"
    end
  end

  # all file tasks used to create fules and tasks
  # must be full paths so they are all unique
  # and no file task will be messed up ???

  files = FileList.new(File.expand_path('*'));

  # public tasks (targets) seen by parent namespace
  task :subtest => [ "#{@me}:subtest", files ].flatten do |t|
     puts "submake test"
  end

end # end private module
This topic is locked and can not be replied to.