require 'reap/tool' module Reap module Systems def self.registry @registry ||= {} end def self.current System.factory end # = System # # Source Control system base class. class System < Tool include Utilities def self.registry Systems.registry end def self.register(*names) registry[name] = self end def self.inherited(base) registry[base.basename.downcase] = base end def self.factory(name=nil) name ||= detect registry[name] end def self.detect scm = %w(.svn .git .hg _darcs CVS).find{ |f| File.exist?(f) } case scm when '.svn' then 'svn' when '.git' then 'git' when 'CVS' then 'cvs' when '_darcs' then 'darcs' when '.hg' then 'hg' end end end end end