Sha256: f564131ca1aaa2d823ee014adfa49a22e45d1f156eb3a93d0e422d66cfe14f60

Contents?: true

Size: 676 Bytes

Versions: 2

Compression:

Stored size: 676 Bytes

Contents

require 'scm/git'
require 'scm/hg'
require 'scm/svn'

module SCM
  # SCM control directories and the SCM classes
  DIRS = {
    '.git' => Git,
    '.hg' => Hg,
    '.svn' => SVN
  }

  #
  # Determines the SCM used for a repository.
  #
  # @param [String] path
  #   The path of the repository.
  #
  # @return [Repository]
  #   The SCM repository.
  #
  # @raise [RuntimeError]
  #   The exact SCM could not be determined.
  #
  def SCM.new(path)
    path = File.expand_path(path)

    DIRS.each do |name,repo|
      dir = File.join(path,name)

      return repo.new(path) if File.directory?(dir)
    end

    raise("could not determine the SCM of #{path.dump}")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scm-0.1.0.pre2 lib/scm/scm.rb
scm-0.1.0.pre1 lib/scm/scm.rb