Class: Kuby::Docker::DockerURI
- Inherits:
-
Object
- Object
- Kuby::Docker::DockerURI
- Extended by:
- T::Sig
- Defined in:
- lib/kuby/docker/docker_uri.rb
Constant Summary collapse
- DEFAULT_REGISTRY_HOST =
T.let('index.docker.io'.freeze, String)
- DEFAULT_REGISTRY_PORT =
T.let(443, Integer)
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host, port, path) ⇒ DockerURI
constructor
A new instance of DockerURI.
Constructor Details
#initialize(host, port, path) ⇒ DockerURI
Returns a new instance of DockerURI.
38 39 40 41 42 |
# File 'lib/kuby/docker/docker_uri.rb', line 38 def initialize(host, port, path) @host = host @port = port @path = path end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
29 30 31 |
# File 'lib/kuby/docker/docker_uri.rb', line 29 def host @host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
35 36 37 |
# File 'lib/kuby/docker/docker_uri.rb', line 35 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
32 33 34 |
# File 'lib/kuby/docker/docker_uri.rb', line 32 def port @port end |
Class Method Details
.parse(url) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kuby/docker/docker_uri.rb', line 12 def self.parse(url) if idx = url.index('://') url = url[(idx + 3)..-1] || '' end host_port, *path = url.split('/') host, port, *path = if host_port =~ /[.:]/ hst, prt = T.must(host_port).split(':') [T.must(hst), prt || DEFAULT_REGISTRY_PORT, *path] else [DEFAULT_REGISTRY_HOST, DEFAULT_REGISTRY_PORT, host_port, *path] end new(host.to_s, port.to_i, (path || []).join('/')) end |