From: Jim Weirich Date: 2004-09-10T02:58:40+09:00 Subject: Re: Rakeforms T. Onoma said: > On Thursday 09 September 2004 02:12 am, Jim Weirich wrote: >> Could you provide a specific example of how you use this? > > BTW, it doesn't seem like there is much demand for such a feature built > directly into rake. Not that it's a bad idea of anything, but unless you > have a keen interest otherwise, I'll just withdraw my proposal. Thanks for the proposal. I always like feedback ... I'm just trying to understand the utility of what you suggest. Why not just do this ... # RakeSetup.rb ------------------------------------------------- PKG_TEST_DIR = "test" PKG_TEST_FILES = ['test/*_test.rb', 'test/**/*_test.rb'] # Rakefile ----------------------------------------------------- require 'rake/testtask' require 'RakeSetup' ## # = Default Task ## desc "Default Task (test)" task :default => [ :test ] ## # = Run Unit Tests ## Rake::TestTask.new("test") { |t| #t.desc "Run all tests" t.libs << PKG_TEST_DIR PKG_TEST_FILES.each { |pat| t.pattern = pat } t.verbose = true } ----------------------------------------------------------------- Isn't the above functionally the same as the Yaml version, but without introducing yet another library. (BTW, I know this is just an example, but assigning the pattern field twice won't do what you think. The only reason this works is that the second patterns matches all the files (and more) that the first pattern matches.) (Not quite a rant, but some pointed observations about tools below) Rake is unusual in that if you know Make (and to a lesser degree, ant), you can transfer that knowledge to Rake fairly easily. Mostly its just a change in the syntax. However, Rake does not suffer the same limitations as Make, and things you did in make to get around some of those limitations are not needed in Rake. I find this to be intuitively true, but difficult to communicate to those who haven't used Rake. A good example comes from an question I received this past week. Someone had to run Rake under two different environments and the dependencies in each environment were different. The question was how can one declare dependencies. The key to answering the problem is to remember that a Rakefile is a full powered Ruby program and that task declarations are nothing more than method calls. The simple answer was: task :doit do # Common actions for task doit end if in_environment_a? task :doit => [:dependencies_in_environment_a] else task :doit => [:dependencies_in_environment_b] end Just as Dijkstra observed "A Programming Language is a tool that has profound influence on our thinking habits", so do the tool we choose. -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)