Class: Pullr::RemoteRepository

Inherits:
Object
  • Object
show all
Includes:
Repository
Defined in:
lib/pullr/remote_repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Repository

#infer_scm_from_dir, #infer_scm_from_uri

Constructor Details

#initialize(options = {}) ⇒ RemoteRepository

Initializes the remote repository.

Parameters:

  • options (Hash) (defaults to: {})

    Options for the remote repository.

Options Hash (options):

  • :uri (URI::Generic)

    The URI of the remote repository.

  • :scm (Symbol, String)

    The SCM used for the remote repository.



28
29
30
31
32
33
34
35
36
37
38
# 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

Instance Attribute Details

#scmObject (readonly)

The SCM that manages the remote repository



11
12
13
# File 'lib/pullr/remote_repository.rb', line 11

def scm
  @scm
end

#uriObject (readonly)

The URI of the remote repository



14
15
16
# File 'lib/pullr/remote_repository.rb', line 14

def uri
  @uri
end

Instance Method Details

#nameString

The name of the repository.

Returns:

  • (String)

    The remote repository name.

Since:

  • 0.1.2



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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) ⇒ Repository

Clones the remote repository into the given destination.

Parameters:

  • dest (String) (defaults to: nil)

    The destination directory to clone the repository into.

Returns:



76
77
78
79
80
# File 'lib/pullr/remote_repository.rb', line 76

def pull(dest=nil)
  scm_pull(@uri,dest)

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