# Rake project structure,? good?

**URL:** <https://www.ruby-forum.com/t/rake-project-structure-good/157976>\
**Category:** Ruby\
**Created:** [January 17, 2009, 6:22am UTC](https://www.ruby-forum.com/t/rake-project-structure-good/157976 "2009-01-17T06:22:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7993a0/32.png) [@peterk](https://www.ruby-forum.com/u/peterk)\
**Post date:** [January 17, 2009, 6:22am UTC](https://www.ruby-forum.com/t/rake-project-structure-good/157976/1 "2009-01-17T06:22:04Z")

</div>

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
