From djberg96 at gmail.com Mon Dec 3 01:07:40 2007 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 02 Dec 2007 23:07:40 -0700 Subject: [Rake-devel] Test tasks, warnings on by default? In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB023D2D1C@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <47539D2C.7010106@gmail.com> Josh Knowles wrote: > On 11/28/07, Berger, Daniel wrote: >> Hi, >> >> What would people think about turning warnings on by default for test >> tasks? > > Unfortunately this will blow up on all Rails projects as Rails emits > a ton of warnings. That's a Rails issue. They can either fix the warnings or disable them. Regards, Dan From adam.q.salter at gmail.com Sat Dec 22 23:41:31 2007 From: adam.q.salter at gmail.com (Adam Salter) Date: Sun, 23 Dec 2007 15:41:31 +1100 Subject: [Rake-devel] Using new Rake arguments Message-ID: <026CA0A3-4CF0-4003-829C-4A3F3706E705@gmail.com> Dear all, I have seen that Rake has task arguments now. Sounds great and useful. How do I _actually_ use them? ;) Some examples would be good. e.g. ?? rake upload[filename1, filename2] rake autoinstall[dir=abcd, options=123] and how do I define these task arguments? I'm hoping task :upload do |file1, file2| # upload or whatever end or even task :autoinstall do |args| options = options.merge(args) install_dir = args[:dir] # move etc. end Just threw these together... probably completely off-base. Thanks, -Adam From jim.weirich at gmail.com Sun Dec 23 03:07:25 2007 From: jim.weirich at gmail.com (Jim Weirich) Date: Sun, 23 Dec 2007 03:07:25 -0500 Subject: [Rake-devel] Using new Rake arguments In-Reply-To: <026CA0A3-4CF0-4003-829C-4A3F3706E705@gmail.com> References: <026CA0A3-4CF0-4003-829C-4A3F3706E705@gmail.com> Message-ID: <30ED5375-A863-47B4-9B3C-3CB9D555E21A@weirichhouse.org> On Dec 22, 2007, at 11:41 PM, Adam Salter wrote: > Dear all, > > I have seen that Rake has task arguments now. Sounds great and useful. > > How do I _actually_ use them? ;) Heh ... sorry. I need to write some docs. But I didn't want to delay the new version for the write-up. > Some examples would be good. > > e.g. ?? > > rake upload[filename1, filename2] > rake autoinstall[dir=abcd, options=123] Close. You have to obey the rules that the shell imposes. So, either: rake upload[filename1,filename2] or rake "upload[filename1, filename2]" (the first has no spaces, the second quotes the arguments. Rules vary on windows and non-ksh/bash shells). > and how do I define these task arguments? You have to tell the task the names of the arguments. E.g. task :upload, :file1, :file2 do ... end If you have dependencies, you use :needs ... task :upload, :file1, :file2, :needs => [:pre_upload] do ... end To get to the args, the task lambdas get an extra argument ... task :upload, :file1, :file2 do |t, args| puts "File one is: #{args.file1}" puts "File two is: #{args.file2}" end Also, args[:file1] will work too. > Just threw these together... probably completely off-base. I'll get some official docs put together soon. Thanks for your patience. -- -- Jim Weirich -- jim at weirichhouse.org From zach.dennis at gmail.com Fri Dec 28 11:00:37 2007 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 28 Dec 2007 11:00:37 -0500 Subject: [Rake-devel] Grabbing tasks in a namespace Message-ID: <85d99afe0712280800n672e02b8h639c036b38bbfd67@mail.gmail.com> There doesn't seem to be a nice interface for grabbing tasks in a namespace. Naively, I tried Rake::NameSpace['my_namespace'] to see if I got a NameSpace returned, which I didn't. I have been using the following workaround: tasks = Rake.application.tasks.select{ |task| task.name =~ /app:dependencies/ } I want to do this because I have a "app:dependencies" task which ensures my system has all of the necessary application dependencies installed. Any task which is put inside of the "app:dependencies" namespace will automatically be run as a dependency check. Is there a better way to do this that exists beside my above workaround? If not, would this functionality be considered if a patch was submitted for the NameSpace#[] method or is it seen as unnecessary to rake itself? Thanks, -- Zach Dennis http://www.continuousthinking.com From spovich at gmail.com Sat Dec 29 01:11:54 2007 From: spovich at gmail.com (John Dell) Date: Fri, 28 Dec 2007 22:11:54 -0800 (PST) Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app Message-ID: <2548101.4681198908714591.JavaMail.root@pyramid.gbdev.com> Hi All, We have a need to redefine 'rake test' in one of our rails apps. I'll spare the reasons for that here, but happy to share if anyone is interested. There is a code snippet .rake file I found that allowed us to redefine the rake task 'test' without touching the original rails task code, and it worked up to rake 0.7.3, but broke with the latest release of rake 0.8.x The sample rake task is here: http://snippets.dzone.com/posts/show/2031 Using that code now bombs with the following: undefined method `last' for {}:Hash /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.0/lib/rake.rb:1654:in `resolve_args' ... My efforts to track this down have failed (so far). Anybody willing to take a peak at this? Or offer suggestions? Thanks, John P.S. The problem is also mentioned in user comments by other folks in the rake 0.8 release here, so I'm not the only one hitting this: https://rubyforge.org/forum/forum.php?thread_id=20548&forum_id=20061 From cfis at savagexi.com Sat Dec 29 01:47:31 2007 From: cfis at savagexi.com (Charlie Savage) Date: Fri, 28 Dec 2007 23:47:31 -0700 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <2548101.4681198908714591.JavaMail.root@pyramid.gbdev.com> References: <2548101.4681198908714591.JavaMail.root@pyramid.gbdev.com> Message-ID: <4775ED83.1090801@savagexi.com> Hi John, Thanks for the code snippet from before - I got a lot of use out of it. To run it with 0.8.x, the first argument to resolve_args should be an array. So: def self.redefine_task(args, &block) task_name, deps = Rake.application.resolve_args([args]) Rake.application.delete_task(task_name) define_task(args, &block) end Hope this helps, Charlie John Dell wrote: > Hi All, > > We have a need to redefine 'rake test' in one of our rails apps. I'll spare the reasons for that here, but happy to share if anyone is interested. > > There is a code snippet .rake file I found that allowed us to redefine the rake task 'test' without touching the original rails task code, and it worked up to rake 0.7.3, but broke with the latest release of rake 0.8.x > > The sample rake task is here: http://snippets.dzone.com/posts/show/2031 > > Using that code now bombs with the following: > > undefined method `last' for {}:Hash > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.0/lib/rake.rb:1654:in `resolve_args' > ... > > My efforts to track this down have failed (so far). Anybody willing to take a peak at this? Or offer suggestions? > > > Thanks, > John > > P.S. The problem is also mentioned in user comments by other folks in the rake 0.8 release here, so I'm not the only one hitting this: > https://rubyforge.org/forum/forum.php?thread_id=20548&forum_id=20061 > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3237 bytes Desc: S/MIME Cryptographic Signature Url : http://rubyforge.org/pipermail/rake-devel/attachments/20071228/1fb9ee01/attachment-0001.bin From spovich at gmail.com Sun Dec 30 02:09:02 2007 From: spovich at gmail.com (John Dell) Date: Sat, 29 Dec 2007 23:09:02 -0800 (PST) Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <4775ED83.1090801@savagexi.com> Message-ID: <274343.4851198998542537.JavaMail.root@pyramid.gbdev.com> Hi Charlie, Awesome! That was it. I also had to change the code for last_comment to last_description. I also found that after I fixed my rake task, that the same problem exists in rails engines tasks that is doing the same thing. I'll post a patch for engines on their forums. Thanks, John Here is the rake task code I'm using now: unless Rake::TaskManager.methods.include?(:redefine_task) module Rake module TaskManager def redefine_task(task_class, args, &block) task_name, deps = resolve_args([args]) task_name = task_class.scope_name(@scope, task_name) deps = [deps] unless deps.respond_to?(:to_ary) deps = deps.collect {|d| d.to_s } task = @tasks[task_name.to_s] = task_class.new(task_name, self) task.application = self task.add_description(@last_description) @last_description = nil task.enhance(deps, &block) task end end class Task class << self def redefine_task(args, &block) Rake.application.redefine_task(self, args, &block) end end end end end ----- "Charlie Savage" wrote: > Hi John, > > Thanks for the code snippet from before - I got a lot of use out of > it. > > To run it with 0.8.x, the first argument to resolve_args should be an > > array. So: > > def self.redefine_task(args, &block) > task_name, deps = Rake.application.resolve_args([args]) > Rake.application.delete_task(task_name) > define_task(args, &block) > end > > Hope this helps, > > Charlie