Class: BuildTool::Server
- Inherits:
-
Object
- Object
- BuildTool::Server
- Defined in:
- lib/build-tool/server.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
The host this repository is hosted.
-
#name ⇒ Object
readonly
Repository name.
-
#path ⇒ Object
The relative path on the server.
-
#protocol ⇒ Object
The protocol used to access the repository.
-
#sshkey ⇒ Object
A ssh key associated with this server.
Instance Method Summary collapse
-
#initialize(name, theurl = nil) ⇒ Server
constructor
Create a repository.
- #to_s ⇒ Object
- #url(user = nil) ⇒ Object
Constructor Details
#initialize(name, theurl = nil) ⇒ Server
Create a repository
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/build-tool/server.rb', line 25 def initialize( name, theurl = nil ) @host = nil @name = nil @path = nil @protocol = nil @sshkey = nil if name.nil? raise StandardError, "The server name has to be set" end @name = name if theurl uri = URI.parse( theurl ) @host = uri.host @protocol = uri.scheme if not uri.path.empty? @path = uri.path end end end |
Instance Attribute Details
#host ⇒ Object
The host this repository is hosted
10 11 12 |
# File 'lib/build-tool/server.rb', line 10 def host @host end |
#name ⇒ Object (readonly)
Repository name
13 14 15 |
# File 'lib/build-tool/server.rb', line 13 def name @name end |
#path ⇒ Object
The relative path on the server
16 17 18 |
# File 'lib/build-tool/server.rb', line 16 def path @path end |
#protocol ⇒ Object
The protocol used to access the repository
19 20 21 |
# File 'lib/build-tool/server.rb', line 19 def protocol @protocol end |
#sshkey ⇒ Object
A ssh key associated with this server
22 23 24 |
# File 'lib/build-tool/server.rb', line 22 def sshkey @sshkey end |
Instance Method Details
#to_s ⇒ Object
67 68 69 |
# File 'lib/build-tool/server.rb', line 67 def to_s "Server: #{url}" end |
#url(user = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/build-tool/server.rb', line 45 def url( user = nil ) if !host raise ConfigurationError, "No host specified for server #{name}" end url = host if user url = "#{user}@#{url}" end if protocol url = "#{protocol}://#{url}" end if path if path[0] == '/' url = "#{url}#{path}" else url = "#{url}/#{path}" end end url end |