Hey~ On Jan 22, 2007, at 8:20 AM, Wayne E. Seguin wrote:
>
> Ezra,
>
> I think this is a great idea and will prove very useful, I would
> definitely use it.
>
> I especially like your great use of method_missing.
>
> I do however forsee a problem with the current idea regarding calls
> like ln_nfs for ln -nfs.
>
> The issue I see here is with commands like:
> mongrel_rails
> mongrel_cluster
> mysqld_safe
> mysql_*
> etc...
>
> As for how to fix this nicely... I'm not sure yet but I see three
> possibilities:
> 1. Use two underscores
> 2. Grab the last part of the underscore
> 3. Use ! at the end to indicate that parameters are intended
>
> Problem with 1 is, well, it's ugly! It is however functional and it
> would be clear what was meant by it
> Problem with 2 is better except for if you call a command with no
> arguments
> Not sure there is much of an issue with 3 unless you intend on using !
> in other places
>
> I'll be monitoring this thread, I'd love to help out here.
>
> Thanks for the great work!
>
> ~Wayne
So I have worked on this some more to incorporate being abel to set
ENV vars per line if you want.
sh.RAILS_ENV('production').mkdir_p 'foo/bar'
#=> RAILS_ENV=production mkdir -p foo/bar
Also I made the method_missing dispatch work if you called
sh.mongrel_cluster_C "config/mongrel.conf" It will now take only the
last text after an underscore and convert that into -args.
But this still doesn't account for calling sh.mongrel_cluster
"start" . the method missing will trigger and split that into mongrel
-cluster start, which is obviously not what we want. Here is a hack I
am using right now to get around this:
%w[
mongrel_rails
mongrel_cluster
mysqld_safe
].each do |m|
define_method(m) do |*args|
@cmdbuff << "[EMAIL PROTECTED] #{args.join(' ')}\n"
self
end
end
I use define_method and a list of known commands with underscores
that should not be picked apart my method missing any more. This gets
around the problem at the expense of the need to compile a big list
of commands that we need to put in that list. If anyone has any other
ideas to handle this case I am all ears.
Jamis asked me to get the update_code task to work with this. Here
you can see a comparison between the old way and the new way:
http://pastie.caboo.se/34983
ALso I have made this into a capistrano plugin that you can use
right now and it already will upload your script to a tmpdir on the
server chmod +x it and then run it and then delete it. I am attaching
the new gem here if you want to try it.
Install the gem and then in your recipe do this:
require 'rubygems'
require 'shell_script_builder/cap_plugin'
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---
shell-script-builder-1.0.1.gem
Description: Binary data
Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- [EMAIL PROTECTED] -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)
