Thanks Jamis. It's good to know the clean way to do it. That (fetch) definitely feels better.
It might be useful for future googlers to know that rails_tag = variables[:rails_tag] || 'rel_1-2-3' works with both cap 2 and cap 1.4.1. Thanks again for the quick reply, Tom On Jul 30, 9:44 am, "Jamis Buck" <[EMAIL PROTECTED]> wrote: > In cap2, the Configuration and Actor classes have been merged into > one, so there is now just a Configuration class. Thus, the former > configuration accessor has been removed. Everything is executed > "within" the configuration instance. > > However, if what you're wanting to do is fetch a variable and return a > default if the variable is not set, there's a cleaner way to do it in > cap2: > > rails_tag = fetch(:rails_tag, "rel_1-2-3") > > - Jamis > > On 7/30/07, Tom Brice <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > I'm working to upgrade to cap2. I have some tasks where I would like > > to be able to pass values in using "cap my_task -s tag=rel_1-1-6" for > > example (FWIW, I am using a variation of the theme proposed by Mike > > Clark[1]). > > > Using cap _1.4.1_ I was able to do this: > > > rails_tag = configuration.variables[:rails_tag] || 'rel_1-2-3' > > > but when I execute the task I get and error: > > /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.0.0/lib/capistrano/ > > configuration/variables.rb:122:in `method_missing': undefined local > > variable or method `configuration' for #<Capistrano::Configuration: > > 0x13c9f00> (NameError) > > > if I change it to: > > > rails_tag = variables[:rails_tag] || 'rel_1-2-3' > > > it works as expected. > > > This was somewhat counter intuitive to me. Is the preferred method to > > access configuration variables simply the 'variables' hash rather than > > 'configuration.variables'? > > > Just looking to clarify. > > > Thanks in advance, > > Tom > > > [1]http://clarkware.com/cgi/blosxom/2007/01/18#ManagingVersionsWithCap --~--~---------~--~----~------------~-------~--~----~ To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/capistrano -~----------~----~----~----~------~----~------~--~---
