Class: BuildTool::Repository
- Inherits:
-
Object
- Object
- BuildTool::Repository
- Defined in:
- lib/build-tool/repository.rb
Overview
Encapsulates a source code repository.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Repository name.
-
#path ⇒ Object
The relative path on the server.
-
#server ⇒ Object
The server this repository is hosted.
-
#sshkey ⇒ Object
Return the ssh key needed to access this repository.
-
#user ⇒ Object
The relative path on the server.
Instance Method Summary collapse
-
#initialize(name) ⇒ Repository
constructor
Create a repository.
- #url ⇒ Object
Constructor Details
#initialize(name) ⇒ Repository
Create a repository
24 25 26 27 28 29 30 31 |
# File 'lib/build-tool/repository.rb', line 24 def initialize(name) if name.nil? raise StandardError, "The repository name has to be set" end @name = name @server = nil @sshkey = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Repository name
9 10 11 |
# File 'lib/build-tool/repository.rb', line 9 def name @name end |
#path ⇒ Object
The relative path on the server
15 16 17 |
# File 'lib/build-tool/repository.rb', line 15 def path @path end |
#server ⇒ Object
The server this repository is hosted
12 13 14 |
# File 'lib/build-tool/repository.rb', line 12 def server @server end |
#sshkey ⇒ Object
Return the ssh key needed to access this repository. If the repository has no key we check the associated server.
35 36 37 38 39 40 41 42 43 |
# File 'lib/build-tool/repository.rb', line 35 def sshkey return @sshkey if @sshkey if !server raise ConfigurationError, "No server specified for repository #{name}" end return server.sshkey end |
#user ⇒ Object
The relative path on the server
18 19 20 |
# File 'lib/build-tool/repository.rb', line 18 def user @user end |
Instance Method Details
#url ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/build-tool/repository.rb', line 45 def url if !server raise ConfigurationError, "No server specified for repository #{name}" end if !server.host raise ConfigurationError, "No host specified for server #{server.name}" end url = server.host if server.path url = "#{url}/#{server.path}" end if user url = "#{user}@#{url}" end if server.protocol url = "#{server.protocol}://#{url}" end if path url = "#{url}/#{path}" end url end |