From cfis at interserv.com Mon Aug 8 03:02:23 2005 From: cfis at interserv.com (Charles F. I. Savage) Date: Mon Aug 8 02:55:02 2005 Subject: [Rake-devel] Custom Task Message-ID: <42F7037F.2070302@interserv.com> Hi everyone, I've created a new custom task called DownloadTask (to help simply a script that downloads about 10 products from the Internet, builds them, and then installs them). The point of a DownloadTask is to download a file via http or ftp, plus the digest, and then verify the file. I realize I could skip the whole download task idea and do something like this: file '/usr/src/myfile.tar.gz' do |task| download_file('http://www.somesite.com/path/myfile.tar.gz') end However, the concept of a download task (with all the code behind it wrapped up) seems to me a more elegant solution. The problem is that I don't see how to fit it into the rake architecture. The simple case, which I've implemented, works fine: download 'http://www.somesite.com/path/myfile.tar.gz' file 'myfile.tar.gz' => 'http://www.somesite.com/path/myfile.tar.gz' However, I run into problems if the file should be downloaded to a different directory. For example, say the rake file is in the directory "build" and the file should be downloaded to "/usr/src". Thus: download 'http://www.somesite.com/path/myfile.tar.gz' file '/usr/src/myfile.tar.gz' => 'http://www.somesite.com/path/myfile.tar.gz' The problem is that there is no way to add a "local_path" option to the download task. Basically, the file task is dependent on the download task, but the download task needs to know from the file task where to put the file. I could do: download 'http://www.somesite.com/path/myfile.tar.gz' do |task| move 'myfile.tar.gz' '/usr/src/' end file '/usr/src/myfile.tar.gz' => 'http://www.somesite.com/path/myfile.tar.gz' But then the download task will always run, because it will check for the file 'myfile.tar.gz' in the local directory, not see it (because the block moved it), then download the code again. Not ideal. Anybody have any advice on how to do this? Thanks for the help, Charlie -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2781 bytes Desc: S/MIME Cryptographic Signature Url : http://rubyforge.org/pipermail/rake-devel/attachments/20050808/abcfe02a/smime.bin From jim at weirichhouse.org Mon Aug 8 07:59:47 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Mon Aug 8 07:55:42 2005 Subject: [Rake-devel] Custom Task In-Reply-To: <42F7037F.2070302@interserv.com> References: <42F7037F.2070302@interserv.com> Message-ID: <200508080759.48544.jim@weirichhouse.org> On Monday 08 August 2005 03:02 am, Charles F. I. Savage wrote: > I could do: > > download 'http://www.somesite.com/path/myfile.tar.gz' do |task| > move 'myfile.tar.gz' '/usr/src/' > end I see a couple of options. One is to do: download 'http://www.somesite.com/path/myfile.tar.gz' do |task| cp 'myfile.tar.gz' '/usr/src/' end Then the downloaded file won't disappear. Another option is to make the download function sensitive to the final directory, e.g. download 'http://www.somesite.com/path/myfile.tar.gz', '/usr/src' Omitting the second argument would default to your current behavior. -- -- 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) From gdf at speakeasy.net Fri Aug 19 08:28:17 2005 From: gdf at speakeasy.net (Greg Fast) Date: Fri Aug 19 08:22:00 2005 Subject: [Rake-devel] Option handling in rake_test_loader.rb Message-ID: <4305D061.6060808@speakeasy.net> Jim, Here's a tiny patch to rake_test_loader.rb that makes it ignore command line options. As it is now, you can't do things like `rake test TESTOPTS="--runner=fox"`, since it tries to load() "--runner=fox". -- Greg Fast gdf@speakeasy.net http://cken.chi.groogroo.com/ -------------- next part -------------- ? rake_test_loader.patch Index: lib/rake/rake_test_loader.rb =================================================================== RCS file: /var/cvs/rake/rake/lib/rake/rake_test_loader.rb,v retrieving revision 1.1 diff -u -r1.1 rake_test_loader.rb --- lib/rake/rake_test_loader.rb 31 Mar 2005 04:44:02 -0000 1.1 +++ lib/rake/rake_test_loader.rb 19 Aug 2005 12:15:07 -0000 @@ -2,4 +2,4 @@ # Load the test files from the command line. -ARGV.each { |f| load f } +ARGV.each { |f| load f unless f =~ /^-/ } -------------- next part -------------- A non-text attachment was scrubbed... Name: gdf.vcf Type: text/x-vcard Size: 267 bytes Desc: not available Url : http://rubyforge.org/pipermail/rake-devel/attachments/20050819/c77290fe/gdf-0001.vcf From jim at weirichhouse.org Fri Aug 19 10:22:19 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Fri Aug 19 10:15:57 2005 Subject: [Rake-devel] Option handling in rake_test_loader.rb In-Reply-To: <4305D061.6060808@speakeasy.net> References: <4305D061.6060808@speakeasy.net> Message-ID: <61817.192.223.163.6.1124461339.squirrel@weirichhouse.org> Greg Fast said: > Jim, > > Here's a tiny patch to rake_test_loader.rb that makes it ignore command > line options. As it is now, you can't do things like `rake test > TESTOPTS="--runner=fox"`, since it tries to load() "--runner=fox". Hmmm ... I seem to have no problems with TESTOPTS="--runner=fox". For example, given a Rakefile: task :default do puts "Options: [#{ENV['TESTOPTS']}]" end The following command seems to work fine: C:\weirich\pgm\rake>rake TESTOPTS="--runner=fox" (in C:/weirich/pgm/rake) Options: [--runner=fox] This was on a windows XP box. My linux box behaves in the same way. What platform were you on where you had trouble. -- -- 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) From gdf at speakeasy.net Fri Aug 19 13:25:48 2005 From: gdf at speakeasy.net (Greg Fast) Date: Fri Aug 19 13:19:30 2005 Subject: [Rake-devel] Option handling in rake_test_loader.rb In-Reply-To: <61817.192.223.163.6.1124461339.squirrel@weirichhouse.org> References: <4305D061.6060808@speakeasy.net> <61817.192.223.163.6.1124461339.squirrel@weirichhouse.org> Message-ID: <20050819122548.A22486@speakeasy.net> On Fri, Aug 19, 2005 at 02:22:19PM -0000, Jim Weirich wrote: > > Here's a tiny patch to rake_test_loader.rb that makes it ignore command > > line options. As it is now, you can't do things like `rake test > > TESTOPTS="--runner=fox"`, since it tries to load() "--runner=fox". > > Hmmm ... I seem to have no problems with TESTOPTS="--runner=fox". For > example, given a Rakefile: I'm on linux, ruby-1.8.2, with (gem) rake 0.5.4. I'm doing this in my rakefile: Rake::TestTask.new( :xmltest ) do |t| t.libs << "test" t.test_files = tf t.verbose = true t.options = "--runner=fox" end And getting this (without the modification to rake_test_loader): % rake test (in /home/gfast/cheese/rscm-accurev) ruby -Ilib:test "/opt/ruby-1.8.2/lib/ruby/gems/1.8/gems/rake-0.5.4/lib/rake/rake_test_loader.rb" "test/t_scrubio.rb" "test/t_load.rb" "test/t_filterio.rb" "test/t_xmlmapper.rb" "test/t_command.rb" "test/t_api.rb" --runner=fox /opt/ruby-1.8.2/lib/ruby/gems/1.8/gems/rake-0.5.4/lib/rake/rake_test_loader.rb:5:in `load': No such file to load -- --runner=fox (LoadError) from /opt/ruby-1.8.2/lib/ruby/gems/1.8/gems/rake-0.5.4/lib/rake/rake_test_loader.rb:5 from /opt/ruby-1.8.2/lib/ruby/gems/1.8/gems/rake-0.5.4/lib/rake/rake_test_loader.rb:5:in `each' from /opt/ruby-1.8.2/lib/ruby/gems/1.8/gems/rake-0.5.4/lib/rake/rake_test_loader.rb:5 The problem is in the way rake_test_loader.rb handles the command line, not rake itself. -- Greg Fast gdf@speakeasy.net http://cken.chi.groogroo.com/ From jim at weirichhouse.org Fri Aug 19 14:54:13 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Fri Aug 19 14:47:50 2005 Subject: [Rake-devel] Option handling in rake_test_loader.rb In-Reply-To: <20050819122548.A22486@speakeasy.net> References: <4305D061.6060808@speakeasy.net><61817.192.223.163.6.1124461339.squirrel@weirichhouse.org> <20050819122548.A22486@speakeasy.net> Message-ID: <6210.192.223.163.6.1124477653.squirrel@weirichhouse.org> Greg Fast said: > The problem is in the way rake_test_loader.rb handles the command > line, not rake itself. Oops! Sorry, I missunderstood the problem. Thanks for the fix. -- -- 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) From gdf at speakeasy.net Fri Aug 19 21:12:53 2005 From: gdf at speakeasy.net (Greg Fast) Date: Fri Aug 19 21:06:31 2005 Subject: [Rake-devel] Another small patch Message-ID: <43068395.6050009@speakeasy.net> Here's another small patch, this time to testtask.rb . It adds a 'ruby_opts' attr to the TestTask which lets you supply extra command line arguments to ruby when running tests. I'm using this to run my tests under a custom testrunner (http://cken.chi.groogroo.com/svn/misc/trunk/rscm-accurev/lib/test/unit/ui/xml/testrunner.rb, which generates xml summaries), using a task definition like this: Rake::TestTask.new( :xmltest ) do |t| t.libs << "test" t.test_files = test_files t.verbose = true t.ruby_opts << '-rtest/unit/ui/xml/testrunner' ENV['XMLTEST_OUTPUT'] = "#{TEST_OUTPUT}/testresults.xml" t.options = "--runner=xml" end -- Greg Fast gdf@speakeasy.net http://cken.chi.groogroo.com/ -------------- next part -------------- Index: lib/rake/testtask.rb =================================================================== RCS file: /var/cvs/rake/rake/lib/rake/testtask.rb,v retrieving revision 1.27 diff -u -r1.27 testtask.rb --- lib/rake/testtask.rb 13 Apr 2005 02:54:16 -0000 1.27 +++ lib/rake/testtask.rb 20 Aug 2005 00:31:35 -0000 @@ -66,6 +66,9 @@ # attr_accessor :loader + # Array of commandline options to pass to ruby when running test loader. + attr_accessor :ruby_opts + # Explicitly define the list of test files to be included in a # test. +list+ is expected to be an array of file names (a # FileList is acceptable). If both +pattern+ and +test_files+ are @@ -84,6 +87,7 @@ @verbose = false @warning = false @loader = :rake + @ruby_opts = [] yield self if block_given? @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil? define @@ -92,7 +96,6 @@ # Create the tasks defined by this task lib. def define lib_path = @libs.join(File::PATH_SEPARATOR) - warning_flag = (@warning ? "-w " : "") desc "Run tests" + (@name==:test ? "" : " for #{@name}") task @name do run_code = '' @@ -106,7 +109,12 @@ when :rake rake_loader end - ruby "-I#{lib_path} #{warning_flag}\"#{run_code}\" " + + @ruby_opts.unshift( "-I#{lib_path}" ) + if @warning + @ruby_opts.unshift( "-w" ) + end + ruby @ruby_opts.join(" ") + + " \"#{run_code}\" " + file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + " #{option_list}" end From cfis at interserv.com Sat Aug 20 02:36:08 2005 From: cfis at interserv.com (Charles F. I. Savage) Date: Sat Aug 20 02:28:18 2005 Subject: [Rake-devel] Custom Task In-Reply-To: <200508080759.48544.jim@weirichhouse.org> References: <42F7037F.2070302@interserv.com> <200508080759.48544.jim@weirichhouse.org> Message-ID: <4306CF58.2090807@interserv.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2781 bytes Desc: S/MIME Cryptographic Signature Url : http://rubyforge.org/pipermail/rake-devel/attachments/20050820/2b54fe19/smime.bin From cfis at interserv.com Sat Aug 20 02:49:55 2005 From: cfis at interserv.com (Charles F. I. Savage) Date: Sat Aug 20 02:42:04 2005 Subject: [Rake-devel] Passing Command Line Values to a Rakefile? Message-ID: <4306D293.8080609@interserv.com> Is there a way to pass options to a Rakefile via the command-line? I'm automating setting up a Posgresql database for use with Rails. The logic is create a database, add in plpgsql support, then add in the appropriate schemas. So something like this: # Create a database task :create_database do |task| command = "createdb my_database" execute_command command end # Now install the plpgsql language task :setup_plpgsql => :create_database do |task| command = "createlang plpgsql" execute_command command end Now, let's say I want to do it for 3 separate databases. One option is something like this: DATABASES = %w[dev test production] task :create_database do |task| DATABASES.each do |database| command = %{createdb #{database}} execute_command command end end However, I'd much rather be able to pass in the database name to the script. Thus something like this from a shell script or other Ruby code: rake -f MyRakefile --options="database=test" rake -f MyRakefile --options="database=deploy" rake -f MyRakefile --options="database=production" Thanks, Charlie -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2781 bytes Desc: S/MIME Cryptographic Signature Url : http://rubyforge.org/pipermail/rake-devel/attachments/20050820/e86c5f28/smime-0001.bin From jim at weirichhouse.org Sat Aug 20 18:27:53 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Sat Aug 20 18:22:36 2005 Subject: [Rake-devel] Passing Command Line Values to a Rakefile? In-Reply-To: <4306D293.8080609@interserv.com> References: <4306D293.8080609@interserv.com> Message-ID: <200508201827.53729.jim@weirichhouse.org> On Saturday 20 August 2005 02:49 am, Charles F. I. Savage wrote: > However, I'd much rather be able to pass in the database name to the > script. ?Thus something like this from a shell script or other Ruby code: > > rake -f MyRakefile --options="database=test" > rake -f MyRakefile --options="database=deploy" > rake -f MyRakefile --options="database=production" You can say: rake -f MyRakefile DATABASE=production The specified value will be placed in the ENV hash (e.g. ENV['DATABASE']). -- -- 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) From cfis at interserv.com Sat Aug 20 18:46:53 2005 From: cfis at interserv.com (Charles F. I. Savage) Date: Sat Aug 20 18:39:00 2005 Subject: [Rake-devel] Passing Command Line Values to a Rakefile? In-Reply-To: <200508201827.53729.jim@weirichhouse.org> References: <4306D293.8080609@interserv.com> <200508201827.53729.jim@weirichhouse.org> Message-ID: <4307B2DD.9080105@interserv.com> Excellent. Thanks. Charlie Jim Weirich wrote: > On Saturday 20 August 2005 02:49 am, Charles F. I. Savage wrote: > >> However, I'd much rather be able to pass in the database name to the >> script. Thus something like this from a shell script or other Ruby code: >> >> rake -f MyRakefile --options="database=test" >> rake -f MyRakefile --options="database=deploy" >> rake -f MyRakefile --options="database=production" >> > > You can say: > rake -f MyRakefile DATABASE=production > > The specified value will be placed in the ENV hash (e.g. ENV['DATABASE']). > > -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2781 bytes Desc: S/MIME Cryptographic Signature Url : http://rubyforge.org/pipermail/rake-devel/attachments/20050820/422225cc/smime.bin From felkinator-ror at yahoo.com Sun Aug 21 11:31:56 2005 From: felkinator-ror at yahoo.com (felkinator-ror@yahoo.com) Date: Sun Aug 21 11:25:29 2005 Subject: [Rake-devel] Can we make the rake class names more unique? Message-ID: <20050821153156.57996.qmail@web33013.mail.mud.yahoo.com> I'm working with rails and trying to use migrations with my app. One of the tables I need to migrate happens to be named 'Task'. I spent a couple hours yesterday trying to get my migration to work, which was just a minor variation on the example from the documentation. It appears the reason is a name space collision -- I was expecting an 'ActiveRecord' Task, but I was getting the Rake Task. How about changing Task to RakeTask, or RkTask, or something like that? How about adding a prefix to all rake internal classes? Is there another better solution? -Kelly ------------------ http://www.kellyfelkins.org/ From Patrick.Bennett at inin.com Sun Aug 21 14:35:54 2005 From: Patrick.Bennett at inin.com (Bennett, Patrick) Date: Sun Aug 21 14:29:28 2005 Subject: [Rake-devel] Can we make the rake class names more unique? Message-ID: <260A0A30F9017945932CC4F7B911B33901786F2E@i3mail1.i3domain.inin.com> If you ask me, Rails is the one at fault here. Since Rails can generate class names for tables that can have *any* name, it should ensure they're in an appropriately 'safe' namespace. --- Original Message --- From: "felkinator-ror@yahoo.com" Sent: Sun 8/21/2005 10:37 am To: "rake-devel@rubyforge.org" Subject: [Rake-devel] Can we make the rake class names more unique? I'm working with rails and trying to use migrations with my app. One of the tables I need to migrate happens to be named 'Task'. I spent a couple hours yesterday trying to get my migration to work, which was just a minor variation on the example from the documentation. It appears the reason is a name space collision -- I was expecting an 'ActiveRecord' Task, but I was getting the Rake Task. How about changing Task to RakeTask, or RkTask, or something like that? How about adding a prefix to all rake internal classes? Is there another better solution? -Kelly ------------------ http://www.kellyfelkins.org/ _______________________________________________ Rake-devel mailing list Rake-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/rake-devel From jim at weirichhouse.org Sun Aug 21 15:38:54 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Sun Aug 21 15:33:26 2005 Subject: [Rake-devel] Can we make the rake class names more unique? In-Reply-To: <20050821153156.57996.qmail@web33013.mail.mud.yahoo.com> References: <20050821153156.57996.qmail@web33013.mail.mud.yahoo.com> Message-ID: <200508211538.54658.jim@weirichhouse.org> On Sunday 21 August 2005 11:31 am, felkinator-ror@yahoo.com wrote: > [...] It appears the reason is a name space > collision -- I was expecting an 'ActiveRecord' Task, > but I was getting the Rake Task. > > How about changing Task to RakeTask, or RkTask, or > something like that? I have moved the Task, FileTask and FileCreationTask into the Rake module so they do not pollute the top level namespace. This means that Rakefiles that explicitly referenced those classes will fail. As a workaround, I have added a --classic-namespace (or -C) option to rake to allow such rakefiles to continue to work. The changes are in CVS head and a beta version is available. If you want to try the beta, update with the following command: gem update rake --source http://onestepback.org/betagems Assuming I hit no snags with this change, it will be included with the next release. -- -- 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) From jim at weirichhouse.org Sun Aug 21 15:40:31 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Sun Aug 21 15:35:01 2005 Subject: [Rake-devel] Option handling in rake_test_loader.rb In-Reply-To: <4305D061.6060808@speakeasy.net> References: <4305D061.6060808@speakeasy.net> Message-ID: <200508211540.31687.jim@weirichhouse.org> On Friday 19 August 2005 08:28 am, Greg Fast wrote: > Jim, > > Here's a tiny patch to rake_test_loader.rb that makes it ignore command > line options. As it is now, you can't do things like `rake test > TESTOPTS="--runner=fox"`, since it tries to load() "--runner=fox". I've included your two changes into the CVS head and have made a beta release. If you wish to try the beta, update rake with ... gem update rake --source http://onestepback.org -- -- 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)