Sha256: cc9db42cf1f2395cea7ac6eb8c73d5bf9163aa78ddc572c3e083dc74f9c1706f

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'pullr/exceptions/ambigious_uri'
require 'pullr/repository'
require 'pullr/local_repository'

module Pullr
  class RemoteRepository

    include Repository

    # The SCM that manages the remote repository
    attr_reader :scm

    # The URI of the remote repository
    attr_reader :uri

    #
    # Initializes the remote repository.
    #
    # @param [Hash] options
    #   Options for the remote repository.
    #
    # @option options [URI::Generic] :uri
    #   The URI of the remote repository.
    #
    # @option options [Symbol, String] :scm
    #   The SCM used for the remote repository.
    #
    def initialize(options={})
      super(options)

      infer_scm_from_uri unless @scm

      unless @scm
        raise(AmbigiousURI,"could not infer the SCM used for the URI #{@uri}",caller)
      end

      extend SCM.lookup(@scm)
    end

    #
    # Clones the remote repository into the given destination.
    #
    # @param [String] dest
    #   The destination directory to clone the repository into.
    #
    # @return [Repository]
    #   The cloned repository.
    #
    def pull(dest=nil)
      scm_pull(@uri,dest)

      return LocalRepository.new(:path => dest, :scm => @scm)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pullr-0.1.1 lib/pullr/remote_repository.rb