There are two ways to do this. The simplest, and the easiest to use when developing a new SCM module, is to set the :source variable instead of the :scm variable:

  set :source, MyCustomSCM.new(self)

If you look at capistrano/recipes/deploy.rb, you'll see that :source defaults to loading whatever scm is used by the :scm variable, so this just short-circuits that.

The other way to do it is to package and install your own SCM (possibly as a gem). Just make sure that your custom SCM source file exists in that project under the capistrano/recipes/deploy/scm directory. (If you're using gems, you'll also need to make sure your gem is loaded before the cap tries to load the SCM.)

A code snippet is worth a thousand words, so here's what I'm saying. Let's say you've got a custom SCM module for a new SCM called FunkySource. Alright. Your directory layout for your cap plugin would look like this:

  funkysource/
    lib/
      capistrano/
        recipes/
          deploy/
            scm

Under that scm directory, you'd have funkysource.rb, which defines Capistrano::Deploy::SCM::FunkySource. That's all cool. You then create a gemspec and build your plugin as a gem, and install it.

Once your funkysource gem is installed, you can use it in your own deploy.rb like so:

  gem 'funkysource'
  set :scm, :funkysource

If you don't like having to explicitly load the gem, then you can install it without using RubyGems (e.g., using setup.rb or install.rb or some other more manual installation method). Or, you can do as Chuck suggested and manually copy the file to Capistrano's deploy/scm directory, although doing so means that the next time you upgrade Capistrano, your custom SCM class will "disappear".

Hope that all makes some kind of sense.

- Jamis

On Oct 24, 2007, at 3:34 PM, Chuck Remes wrote:


For anyone who wants to write a custom SCM, please note that you need
to place this file within the gem directory at this path:
/path/to/gem/lib/capistrano/recipes/deploy/scm

Otherwise, the system will not find your SCM even if you have loaded
the classes elsewhere. The code in lib/capistrano/recipes/deploy/
scm.rb called upon instantiation of the SCM classes looks for files
in the above-mentioned directory.

module Capistrano
   module Deploy
     module SCM
       def self.new(scm, config={})
         scm_file = "capistrano/recipes/deploy/scm/#{scm}"
         require(scm_file)

         scm_const = scm.to_s.capitalize.gsub(/_(.)/) { $1.upcase }
         if const_defined?(scm_const)
           const_get(scm_const).new(config)
         else
           raise Capistrano::Error, "could not find `#{name}::#
{scm_const}' in `#{scm_file}'"
         end
       rescue LoadError
         raise Capistrano::Error, "could not find any SCM named `#
{scm}'"
       end
     end
   end
end

Perhaps in the future we can patch this so an alternate "plugin"
directory can be defined and searched too.

If I'm off base on how this is supposed to work (I've been wrong
before!) please feel free to correct me.

--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to capistrano- [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/ group/capistrano
-~----------~----~----~----~------~----~------~--~---


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to