Sha256: dcdf1f6c75c533dc8d47fc8e629dd5a85d780a6840f8e0c733f7fd1e3ce8de9c

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'pullr/exceptions/ambigious_repository'
require 'pullr/repository'

module Pullr
  class LocalRepository

    include Repository

    # The path of the repository
    attr_reader :path

    # The SCM used for the repository
    attr_reader :scm

    # Optional URI for the remote repository
    attr_accessor :uri

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

      @path = options[:path]

      unless @scm
        infer_scm_from_dir && infer_scm_from_uri
      end

      unless @scm
        raise(AmbigiousRepository,"could not infer the SCM from the directory #{@path.dump}",caller)
      end

      extend SCM.lookup(@scm)
    end

    #
    # The control directory used by the SCM.
    #
    # @return [String]
    #   The name of the control directory.
    #
    def scm_dir
      dir, scm = SCM::DIRS.find { |dir,scm| scm == @scm }

      return dir
    end

    #
    # Pulls any new updates for the repository down.
    #
    # @param [URI::Generic] uri
    #   Optional URI to pull from.
    #
    def update(uri=self.uri)
      scm_update(@path,uri)
    end
  
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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