Actually, the old version of that recipe would work fine in Cap2,
you'd just get a deprecation warning for the
"Capistrano.configuration" call. There's no need to switch to the new
after() keyword, since "after_update_code" will continue to work as
before.
If you just want to get rid of the deprecation warning:
config = Capistrano::Configuration.respond_to?(:instance) ?
Capistrano::Configuration.instance(:must_exist) :
Capistrano.configuration(:must_exist)
config.load do
# ...
end
Such are the hoops one must jump through to support both cap1 and
cap2. You need to code to the lowest common denominator, which means
newer features (like the before() and after() hooks, and namespaces)
will have to be left out. Life is much better when you can simply
code to cap2. :)
- Jamis
On May 11, 2007, at 8:39 AM, Daniel Morrison wrote:
>
> Hello all,
>
> I have a couple extension libraries that I'd like to make work in both
> cap 1.4 and 2.0. I can't figure out the best way to do this that will
> work in both.
>
> Here is a sample recipe file that I would typically require in my
> deploy.rb
>
> Capistrano.configuration(:must_exist).load do
> desc "Save the current source code revision to version.rb"
> task :save_version_number, :roles => :app do
> run "echo APP_VERSION='#{source.latest_revision}' >
> #{release_path}/lib/version.rb"
> end
>
> desc "Run the save_version_number task after update_code runs."
> task :after_update_code , :roles => :app do
> save_version_number
> end
> end
>
>
> After conversion to 2.0, I have it looking like this:
>
>
> Capistrano::Configuration.instance.load do
> namespace :deploy do
> desc "Save the current source code revision to version.rb"
> task :save_version_number, :roles => :app do
> run "echo APP_VERSION='#{source.latest_revision}' >
> #{release_path}/lib/version.rb"
> end
>
> after :update_code, :save_version_number
> end
> end
>
> My problem is how to get these two versions to live in the same file,
> ideally with less duplication. Any guidance would be greatly
> appreciated!
>
> The code's usefulness is arguable, but it is real code from a Rails
> plugin http://source.collectiveidea.com/public/rails/plugins/
> version_number
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---