Jeroen,
You can use lazily evaluated variables to make sure the work only
happens when it absolutely needs to happen. Something like this:
set :repository do
# do all your work here, and make sure the block
# returns the value you want the repository variable
# to take.
end
The first time you access the repository variable after that, the
block will be evaluated and the result cached, so that subsequent
requests for that variable return the cached value.
Does that help do what you were wanting to do?
- Jamis
On Jan 22, 2007, at 9:17 AM, jeroen wrote:
>
> Hi,
>
> I recently made a little snippet to add support for deploying versions
> of your app, based on SVN tags with a standard naming scheme:
>
> if variables.include?(:version)
>
> # set SVN URL to the specified tag
> # we assume the :repository ends in /trunk
> # ... yeah it's convention over configuration
> path_array = repository.split('/')
> path_array.pop
> # yep, we expect the tag to be named REL-some.version.number
> # again, convention over configuration
> tag_path = path_array.join('/') + '/tags/REL-' + version
> set :repository, tag_path
> # feedback
> puts " * deploying version #{version} from #{tag_path}"
> else
> puts "\n *** WARNING: your are deploying the latest version from
> /trunk"
> puts " *** to deploy a tagged version use (example): cap
> deploy_version -S version=1.0\n\n\n"
> end
>
> I dumped this straight into deploy.rb but that's a bit ugly.
> Ultimately
> I would like to only run this bit of code with deploy and
> deploy_with_migrations. I thought about using ruby's alias, but that
> doesn't work with the way cap does its thing (method_missing IIRC).
>
> Help is much appreciated!
>
> Jeroen
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---