From jonathan.stott at gmail.com Fri Dec 1 07:51:17 2006 From: jonathan.stott at gmail.com (Jonathan Stott) Date: Fri, 1 Dec 2006 12:51:17 +0000 Subject: [Rake-devel] Generating File Tasks Message-ID: <14cf210a0612010451y2def60d7m3ebff1f3b0fe2734@mail.gmail.com> Hi I'm quite new to both make (and very recently) to rake, but I appear to have a problem that is beyond make and I cannot figure out how to do it in rake either. The situation is I have a series of drivers and a series of models, stored in the directories 'driver' and 'model', respectively. The driver code takes a model and performs some calculations with it and any model is valid for any driver. What I would like to be able to do is have some generic code whereby if I add a driver or model, I can type "rake driver_model" and compile the code. I have the code snippet: file "driver_model" => calc_dep("driver_model") do |t| sh "#{CC} #{LDFLAGS} -o #{t.name} #{t.prerequisites.join(" ")} #{LIB}" end def calc_dep(file) dep = file.split("_") dep.collect! { |d| d + ".o" } return dep end which will take driver_model, work out it depends on driver.o and model.o and proceed to build the code, which is just what I want. However, it does require me to have defined driver_model combinations for each executable I wish to create and since I have at last count 5 drivers and 7 models, I would need to make 35 rules to cover each combination and more rules whenever I added another driver or model. So I would like to synthesise the possible driver/model combinations from the available source files at the time of running rake. I think I should be able to do this via : Task.new(task_name,app) and the .enhance(deps) method. within a nested look of the available models and drivers. However, I'm not sure how to find the correct application name, since DRIVERS.each do |d| MODELS.each do |m| Task.new("#{d}_#{m}",Rake.application()) end end puts Task.tasks() will return only manually defined tasks, so I don't think they're being added to the correct application, and while I've looked in the rdoc documentation, I don't understand what I should add... Any help would be appreciated Regards Jonathan From jonathan.stott at gmail.com Sat Dec 2 17:58:04 2006 From: jonathan.stott at gmail.com (Jonathan Stott) Date: Sat, 2 Dec 2006 22:58:04 +0000 Subject: [Rake-devel] Generating File Tasks In-Reply-To: <14cf210a0612010451y2def60d7m3ebff1f3b0fe2734@mail.gmail.com> References: <14cf210a0612010451y2def60d7m3ebff1f3b0fe2734@mail.gmail.com> Message-ID: <14cf210a0612021458t3a71831m329805e359cddc2d@mail.gmail.com> Hi I'm quite new to both make (and very recently) to rake, but I appear to have a problem that is beyond make and I cannot figure out how to do it in rake either. The situation is I have a series of drivers and a series of models, stored in the directories 'driver' and 'model', respectively. The driver code takes a model and performs some calculations with it and any model is valid for any driver. What I would like to be able to do is have some generic code whereby if I add a driver or model, I can type "rake driver_model" and compile the code. I have the code snippet: file "driver_model" => calc_dep("driver_model") do |t| sh "#{CC} #{LDFLAGS} -o #{t.name} #{t.prerequisites.join(" ")} #{LIB}" end def calc_dep(file) dep = file.split("_") dep.collect! { |d| d + ".o" } return dep end which will take driver_model, work out it depends on driver.o and model.o and proceed to build the code, which is just what I want. However, it does require me to have defined driver_model combinations for each executable I wish to create and since I have at last count 5 drivers and 7 models, I would need to make 35 rules to cover each combination and more rules whenever I added another driver or model. So I would like to synthesise the possible driver/model combinations from the available source files at the time of running rake. I think I should be able to do this via : Task.new(task_name,app) and the .enhance(deps) method. within a nested look of the available models and drivers. However, I'm not sure how to find the correct application name, since DRIVERS.each do |d| MODELS.each do |m| Task.new("#{d}_#{m}",Rake.application()) end end puts Task.tasks() will return only manually defined tasks, so I don't think they're being added to the correct application, and while I've looked in the rdoc documentation, I don't understand what I should add... Any help would be appreciated Regards Jonathan PS Apologies if this ends up being double posted, but the list seemed to eat my first email with narry an indication it had been sent 24 hours later ... not even getting my own mail back. From jim at weirichhouse.org Sat Dec 2 19:32:50 2006 From: jim at weirichhouse.org (Jim Weirich) Date: Sat, 02 Dec 2006 19:32:50 -0500 Subject: [Rake-devel] Generating File Tasks In-Reply-To: <14cf210a0612021458t3a71831m329805e359cddc2d@mail.gmail.com> References: <14cf210a0612010451y2def60d7m3ebff1f3b0fe2734@mail.gmail.com> <14cf210a0612021458t3a71831m329805e359cddc2d@mail.gmail.com> Message-ID: <45721B32.8050509@weirichhouse.org> Jonathan Stott wrote: > Hi > > I'm quite new to both make (and very recently) to rake, but I appear > to have a problem that is beyond make and I cannot figure out how to > do it in rake either. > > The situation is I have a series of drivers and a series of models, > stored in the directories 'driver' and 'model', respectively. The > driver code takes a model and performs some calculations with it and > any model is valid for any driver. > > What I would like to be able to do is have some generic code whereby > if I add a driver or model, I can type "rake driver_model" and compile > the code. > I have the code snippet: > > file "driver_model" => calc_dep("driver_model") do |t| > sh "#{CC} #{LDFLAGS} -o #{t.name} #{t.prerequisites.join(" ")} #{LIB}" > end > > def calc_dep(file) > dep = file.split("_") > dep.collect! { |d| d + ".o" } > return dep > end > > which will take driver_model, work out it depends on driver.o and > model.o and proceed to build the code, which is just what I want. > However, it does require me to have defined driver_model combinations > for each executable I wish to create and since I have at last count 5 > drivers and 7 models, I would need to make 35 rules to cover each > combination and more rules whenever I added another driver or model. > > So I would like to synthesise the possible driver/model combinations > from the available source files at the time of running rake. > > I think I should be able to do this via : > > Task.new(task_name,app) > and > the .enhance(deps) method. > > within a nested look of the available models and drivers. However, I'm > not sure how to find the correct application name, since > > DRIVERS.each do |d| > MODELS.each do |m| > Task.new("#{d}_#{m}",Rake.application()) > end > end > > puts Task.tasks() I haven't had a chance to look at this in detail, but I always use the standard task definition methods for my dynamically generated tasks. Try this: DRIVERS.each do |d| MODELS.each do |m| task "#{d}_#{m}" end end -- Jim Weirich From jonathan.stott at gmail.com Sat Dec 2 20:00:29 2006 From: jonathan.stott at gmail.com (Jonathan Stott) Date: Sun, 3 Dec 2006 01:00:29 +0000 Subject: [Rake-devel] Generating File Tasks In-Reply-To: <45721B32.8050509@weirichhouse.org> References: <14cf210a0612010451y2def60d7m3ebff1f3b0fe2734@mail.gmail.com> <14cf210a0612021458t3a71831m329805e359cddc2d@mail.gmail.com> <45721B32.8050509@weirichhouse.org> Message-ID: <14cf210a0612021700h3ff7f59hda2b7147c22048e7@mail.gmail.com> ...It really didn't occur to me I could have it as simply as that. *shakes his head* That would have saved me so much exasperation on friday. *blush* It seems to work just perfectly though, so thank you! Jonathan From deankassmann at gmail.com Tue Dec 12 12:36:39 2006 From: deankassmann at gmail.com (Dean Kassmann) Date: Tue, 12 Dec 2006 09:36:39 -0800 Subject: [Rake-devel] c++ projects and rake Message-ID: Has anyone on this list done any work in getting rake working on large c++ projects? Any pointers to posts or docs would be greatly appreciated. Cheers, Dean From pabs at pablotron.org Tue Dec 12 22:06:41 2006 From: pabs at pablotron.org (Paul Duncan) Date: Tue, 12 Dec 2006 22:06:41 -0500 Subject: [Rake-devel] [PATCH] Add PGP Signing to PackageTask and GemPackageTask Message-ID: <20061213030641.GQ11030@vault.home.pablotron.org> Attached is a patch against the trunk that adds basic PGP signing support (via GnuPG) to PackageTask. It adds an accessor attribute named "need_pgp_signature". If set, PackageTask and GemPackageTask add additional file tasks which use GnuPG (http://gnupg.org/) to create detached PGP signatures of each package file type (.tgz, .tar.gz, .zip, and .gem). If that sounds like a bunch of technobabble, don't panic! It's actually really easy to use. Say you've got the following task: Rake::GemPackageTask.new(gem_spec) do |pkg| pkg.need_tar_gz = true end To add PGP signing support, you'd make it look like so: Rake::GemPackageTask.new(gem_spec) do |pkg| pkg.need_tar_gz = true pkg.need_pgp_signature = true end If you'd like, you can also change the PGP program and/or signature file extension to something else. Here's an example: Rake::GemPackageTask.new(gem_spec) do |pkg| pkg.need_tar_gz = true # create pgp signatures for package files pkg.need_pgp_signature = true # use gpg2 and don't ASCII-armor the signature file pkg.pgp_command = 'gpg2 -b' # set the PGP signature extension to .sig pkg.pgp_file_extension = 'sig' end Personally, I like this feature and find it incredibly useful, although I could be persuaded by the argument that it doesn't really belong in PackageTask. So, at the moment I'm just tossing this out for discussion, with the not-so-secret hope of sneaking it in under the radar and into an actual release ;-). Anyway, the patch is attached. If you've got a munge-happy email client, it's also available online at the following URL: http://pablotron.org/files/rake-20061212-pkg_pgp_sign.diff These changes also work just fine under Rake 0.7.1, although the patch doesn't apply cleanly due to minor whitespace differences in 0.7.1. If you're interested in trying out this patch without upgrading to the development version of Rake, a patch against 0.7.1 is available here: http://pablotron.org/files/rake-0.7.1-pkg_pgp_sign.diff The PGP signatures for both files can be found here: http://pablotron.org/files/rake-20061212-pkg_pgp_sign.diff.asc http://pablotron.org/files/rake-0.7.1-pkg_pgp_sign.diff.asc Happy raking... -- Paul Duncan OpenPGP Key ID: 0x82C29562 http://www.pablotron.org/ http://www.paulduncan.org/ -------------- next part -------------- Index: lib/rake/packagetask.rb =================================================================== --- lib/rake/packagetask.rb (revision 577) +++ lib/rake/packagetask.rb (working copy) @@ -68,6 +68,15 @@ # List of files to be included in the package. attr_accessor :package_files + # True if a detached, ASCII-armored signature of each package file should be produced (default is false). + attr_accessor :need_pgp_signature + + # Command to create detached OpenPGP signature files (default is 'gpg -ba'). + attr_accessor :pgp_command + + # Extension for detached OpenPGP signature files (default is 'asc'). + attr_accessor :pgp_file_extension + # Create a Package Task with the given name and version. def initialize(name=nil, version=nil) init(name, version) @@ -85,6 +94,11 @@ @need_tar_gz = false @need_tar_bz2 = false @need_zip = false + + # pgp defaults (set to use GnuPG by default) + @need_pgp_signature = false + @pgp_command = 'gpg -ba' + @pgp_file_extension = 'asc' end # Create the tasks defined by this task library. @@ -117,6 +131,8 @@ sh %{tar #{flag}cvf #{file} #{package_name}} end end + + pgp_task_for(file) if @need_pgp_signature end end @@ -126,6 +142,8 @@ chdir(package_dir) do sh %{zip -r #{zip_file} #{package_name}} end + + pgp_task_for(zip_file) if @need_pgp_signature end end @@ -148,6 +166,18 @@ self end + def pgp_task_for(src_file) + src_path = "#@package_dir/#{src_file}" + sig_path = "#{src_path}.#@pgp_file_extension" + + task :package => [sig_path] + file sig_path => [src_path] do + chdir(@package_dir) do + sh %{#@pgp_command #{src_file}} + end + end + end + def package_name @version ? "#{@name}-#{@version}" : @name end Index: lib/rake/gempackagetask.rb =================================================================== --- lib/rake/gempackagetask.rb (revision 577) +++ lib/rake/gempackagetask.rb (working copy) @@ -86,6 +86,8 @@ } } end + + pgp_task_for(gem_file) if @need_pgp_signature end def gem_file -------------- next part -------------- diff -ur rake-0.7.1/lib/rake/gempackagetask.rb rake-0.7.1-pgp_sign/lib/rake/gempackagetask.rb --- rake-0.7.1/lib/rake/gempackagetask.rb 2006-12-12 21:48:03.000000000 -0500 +++ rake-0.7.1-pgp_sign/lib/rake/gempackagetask.rb 2006-12-12 21:40:04.000000000 -0500 @@ -86,6 +86,8 @@ } } end + + pgp_task_for(gem_file) if @need_pgp_signature end def gem_file diff -ur rake-0.7.1/lib/rake/packagetask.rb rake-0.7.1-pgp_sign/lib/rake/packagetask.rb --- rake-0.7.1/lib/rake/packagetask.rb 2006-12-12 21:48:03.000000000 -0500 +++ rake-0.7.1-pgp_sign/lib/rake/packagetask.rb 2006-12-12 21:46:38.000000000 -0500 @@ -68,6 +68,15 @@ # List of files to be included in the package. attr_accessor :package_files + # True if a detached, ASCII-armored signature of each package file should be produced (default is false). + attr_accessor :need_pgp_signature + + # Command to create detached OpenPGP signature files (default is 'gpg -ba'). + attr_accessor :pgp_command + + # Extension for detached OpenPGP signature files (default is 'asc'). + attr_accessor :pgp_file_extension + # Create a Package Task with the given name and version. def initialize(name=nil, version=nil) init(name, version) @@ -85,6 +94,11 @@ @need_tar_gz = false @need_tar_bz2 = false @need_zip = false + + # pgp defaults (set to use GnuPG by default) + @need_pgp_signature = false + @pgp_command = 'gpg -ba' + @pgp_file_extension = 'asc' end # Create the tasks defined by this task library. @@ -117,6 +131,8 @@ sh %{tar #{flag}cvf #{file} #{package_name}} end end + + pgp_task_file(file) if @need_pgp_signature end end @@ -127,6 +143,8 @@ sh %{zip -r #{zip_file} #{package_name}} end end + + pgp_task_file(file) if @need_pgp_signature end directory package_dir @@ -148,6 +166,18 @@ self end + def pgp_task_for(src_file) + src_path = "#@package_dir/#{src_file}" + sig_path = "#{src_path}.#@pgp_file_extension" + + task :package => [sig_path] + file sig_path => [src_path] do + chdir(@package_dir) do + sh %{#@pgp_command #{src_file}} + end + end + end + def package_name @version ? "#{@name}-#{@version}" : @name end -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://rubyforge.org/pipermail/rake-devel/attachments/20061212/d170dec6/attachment.bin From leon at newavenue.net Mon Dec 25 20:05:27 2006 From: leon at newavenue.net (Leon Yeh) Date: Mon, 25 Dec 2006 17:05:27 -0800 Subject: [Rake-devel] Question about namespace In-Reply-To: <20060318142851.GA28028@code-monkey.de> References: <20060318142851.GA28028@code-monkey.de> Message-ID: <45907557.9020809@newavenue.net> After Rails Edge event attending rake tutorial by Jim Weitich, I got fired up to move all of my bash based cron script ( backup, database cleanup, etc ) into rake, so I can chain more tasks together, and create file dependencies between tasks. The idea is to create something like this : \raketasks \cleanup_db.rake \filter_mail.rake \rakefile with each rake file under their own namespace, for example for: [cleanup_db.rake] namespace :cleanup_db def func1 ... end task :default => ... end -------------------------------------- [filter_mail.rake] namespace :filter_mail def func1 ... end task :default => ... end -------------------------------------- [rakefile] require cleanup_db.rake require filter_mail.rake task :default => [filter_mail:default, cleanup_db:default] -------------------------------------- Everythings looks good and appear to be working, however I found that the namespace does not applied to the function. So when a func1 get called, it was executed at both place. Can someone let me know on how to make the function is part of the namespace and will not "collide" or get called twice ? I have not checked if capistrano is the place to do this or I am just mis-using rake. Thanks in advance. Leon Yeh New Avenue Systems Inc. Imagination Delivered. www.newavenue.net From jim at weirichhouse.org Mon Dec 25 20:50:17 2006 From: jim at weirichhouse.org (Jim Weirich) Date: Mon, 25 Dec 2006 20:50:17 -0500 Subject: [Rake-devel] Question about namespace In-Reply-To: <45907557.9020809@newavenue.net> References: <20060318142851.GA28028@code-monkey.de> <45907557.9020809@newavenue.net> Message-ID: <45907FD9.2060300@weirichhouse.org> Leon Yeh wrote: > After Rails Edge event attending rake tutorial by Jim Weitich, I got > fired up to move all of my bash based cron script ( backup, database > cleanup, etc ) into rake, so I can chain more tasks together, and create > file dependencies between tasks. [...] > Everythings looks good and appear to be working, however I found > that the namespace does not applied to the function. So when a func1 > get called, it was executed at both place. Really? I would have expected the last definition to override any previous. > Can someone let me know on how to make the function is part of the > namespace and will not "collide" or get called twice ? I have not > checked if capistrano is the place to do this or I am just mis-using > rake. Rake namespaces only control the names for non-file tasks (file tasks are named for the file they represent and so namespaces make no sense for file tasks). Function names do not participate in Rake task namespaces, but can easily be placed in a module, which is the Ruby provided mechanism for managing that. -- -- Jim Weirich jim at weirichhouse.org http://onestepback.org -- In theory, practice and theory are the same. -- In practice, they are different. From leon at newavenue.net Mon Dec 25 23:48:30 2006 From: leon at newavenue.net (Leon Yeh) Date: Mon, 25 Dec 2006 20:48:30 -0800 Subject: [Rake-devel] Question about namespace In-Reply-To: <45907FD9.2060300@weirichhouse.org> References: <20060318142851.GA28028@code-monkey.de> <45907557.9020809@newavenue.net> <45907FD9.2060300@weirichhouse.org> Message-ID: <4590A99E.5060609@newavenue.net> Thanks Jim, by putting the function into the module fixed my problem. Leon Yeh New Avenue Systems Inc. Imagination Delivered. www.newavenue.net Jim Weirich wrote: > Leon Yeh wrote: > > After Rails Edge event attending rake tutorial by Jim Weitich, I got > > fired up to move all of my bash based cron script ( backup, database > > cleanup, etc ) into rake, so I can chain more tasks together, and create > > file dependencies between tasks. > [...] > > Everythings looks good and appear to be working, however I found > > that the namespace does not applied to the function. So when a func1 > > get called, it was executed at both place. > > Really? I would have expected the last definition to override any > previous. > > > Can someone let me know on how to make the function is part of the > > namespace and will not "collide" or get called twice ? I have not > > checked if capistrano is the place to do this or I am just mis-using > > rake. > > Rake namespaces only control the names for non-file tasks (file tasks > are named for the file they represent and so namespaces make no sense > for file tasks). Function names do not participate in Rake task > namespaces, but can easily be placed in a module, which is the Ruby > provided mechanism for managing that. > >