Class: Regrit::RemoteRepo
- Inherits:
-
Object
- Object
- Regrit::RemoteRepo
- Defined in:
- lib/regrit/remote_repo.rb
Constant Summary collapse
- REFS_REGEXP =
/^[0-9a-f]{40}\t\w/i
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#accessible? ⇒ Boolean
Attempt to grab refs.
-
#initialize(uri, options = {}) ⇒ RemoteRepo
constructor
A new instance of RemoteRepo.
-
#private_key_required? ⇒ Boolean
Decide if the URI is likely to require authentication.
-
#ref(named) ⇒ Ref?
Use a git ls-remote to find a single ref.
-
#refs ⇒ Array
Use a git ls-remote to load all repository refs.
Constructor Details
#initialize(uri, options = {}) ⇒ RemoteRepo
Returns a new instance of RemoteRepo.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/regrit/remote_repo.rb', line 11 def initialize(uri, ={}) if uri.nil? || uri.empty? raise InvalidURIError end begin @uri = Gitable::URI.parse(uri) rescue TypeError, Gitable::URI::InvalidURIError raise InvalidURIError end if @uri.interactive_authenticated? raise InvalidURIError end @options = end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/regrit/remote_repo.rb', line 9 def uri @uri end |
Instance Method Details
#accessible? ⇒ Boolean
Attempt to grab refs. If the repository is auth required and a private key is passed, use ssh to attempt access to the repository.
39 40 41 42 43 |
# File 'lib/regrit/remote_repo.rb', line 39 def accessible? !!refs rescue Inaccessible false end |
#private_key_required? ⇒ Boolean
Decide if the URI is likely to require authentication
31 32 33 |
# File 'lib/regrit/remote_repo.rb', line 31 def private_key_required? @uri.ssh? end |
#ref(named) ⇒ Ref?
Use a git ls-remote to find a single ref
55 56 57 |
# File 'lib/regrit/remote_repo.rb', line 55 def ref(named) load_refs(named).detect { |ref| ref.match?(named) } end |
#refs ⇒ Array
Use a git ls-remote to load all repository refs
48 49 50 |
# File 'lib/regrit/remote_repo.rb', line 48 def refs @refs ||= load_refs end |