Rake project structure,? good?

P

Peter Pk

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top