Class: Amp::Repositories::Repository
- Defined in:
- lib/amp/repository/repository.rb
Overview
Repository
This is an abstract class that represents a repository. All repositories must inherit from this class.
Direct Known Subclasses
Instance Method Summary collapse
-
#add_path(path) ⇒ String
Joins the given path with our URL.
-
#can_copy? ⇒ Boolean
can we copy files? Only for local repos.
-
#capable?(capability) ⇒ Boolean, String
Is this repository capable of the given action/format? Or, if the capability has a value assigned to it (like “revlog” = “version2”), what is it?.
-
#get_capabilities ⇒ Object
No-op, to be implemented by remote repo classes.
-
#local? ⇒ Boolean
is the repository a local repo?.
-
#require_capability(capability, purpose) ⇒ Object
Raises an exception if we don’t have a given capability.
Instance Method Details
#add_path(path) ⇒ String
Joins the given path with our URL. Necessary due to the difference between local and remote repos.
84 85 86 87 88 89 90 91 |
# File 'lib/amp/repository/repository.rb', line 84 def add_path(path) myurl = self.url if myurl.end_with? '/' myurl + path else myurl + '/' + path end end |
#can_copy? ⇒ Boolean
can we copy files? Only for local repos.
74 75 76 |
# File 'lib/amp/repository/repository.rb', line 74 def can_copy? local? end |
#capable?(capability) ⇒ Boolean, String
Is this repository capable of the given action/format? Or, if the capability has a value assigned to it (like “revlog” = “version2”), what is it?
39 40 41 42 |
# File 'lib/amp/repository/repository.rb', line 39 def capable?(capability) get_capabilities @capabilities[capability] end |
#get_capabilities ⇒ Object
No-op, to be implemented by remote repo classes.
46 |
# File 'lib/amp/repository/repository.rb', line 46 def get_capabilities; end |
#local? ⇒ Boolean
is the repository a local repo?
66 67 68 |
# File 'lib/amp/repository/repository.rb', line 66 def local? false end |
#require_capability(capability, purpose) ⇒ Object
Raises an exception if we don’t have a given capability.
54 55 56 57 58 59 60 |
# File 'lib/amp/repository/repository.rb', line 54 def require_capability(capability, purpose) get_capabilities raise RepositoryCapabilityError.new(<<-EOF Can't #{purpose}; remote repository doesn't support the #{capability} capability. EOF ) unless @capabilities[capability] end |