Class: Pullr::RemoteRepository
- Inherits:
-
Object
- Object
- Pullr::RemoteRepository
- Includes:
- Repository
- Defined in:
- lib/pullr/remote_repository.rb
Instance Attribute Summary collapse
-
#scm ⇒ Object
readonly
The SCM that manages the remote repository.
-
#uri ⇒ Object
readonly
The URI of the remote repository.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ RemoteRepository
constructor
Initializes the remote repository.
-
#name ⇒ String
The name of the repository.
-
#pull(dest = nil) ⇒ Repository
Clones the remote repository into the given destination.
Methods included from Repository
#infer_scm_from_dir, #infer_scm_from_uri
Constructor Details
#initialize(options = {}) ⇒ RemoteRepository
Initializes the remote repository.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pullr/remote_repository.rb', line 28 def initialize(={}) super() 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
#scm ⇒ Object (readonly)
The SCM that manages the remote repository
11 12 13 |
# File 'lib/pullr/remote_repository.rb', line 11 def scm @scm end |
#uri ⇒ Object (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
#name ⇒ String
The name of the repository.
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.(@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.
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 |