class Pullr::RemoteRepository

Attributes

scm[R]

The SCM that manages the remote repository

uri[R]

The URI of the remote repository

Public Class Methods

new(options={}) click to toggle source

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.
Calls superclass method Pullr::Repository::new
# File lib/pullr/remote_repository.rb, line 28
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

Public Instance Methods

name() click to toggle source

The name of the repository.

@return [String]

The remote repository name.

@since 0.1.2

# File lib/pullr/remote_repository.rb, line 48
def name
  dirs = File.expand_path(@uri.path).split(File::SEPARATOR)

  unless dirs.empty?
    if @scm == :sub_version
      if dirs[-1] == 'trunk'
        dirs.pop
      elsif (dirs[-2] == 'branches' || dirs[-2] == 'tags')
        dirs.pop
        dirs.pop
      end
    elsif @scm == :git
      dirs.last.gsub!(/\.git$/,'') if dirs.last =~ /\.git$/
    end
  end

  return (dirs.last || @uri.host)
end
pull(dest=nil) click to toggle source

Clones the remote repository into the given destination.

@param [String] dest

The destination directory to clone the repository into.

@return [Repository]

The cloned repository.
# File lib/pullr/remote_repository.rb, line 76
def pull(dest=nil)
  scm_pull(@uri,dest)

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