Class: Barbeque::DockerImage
- Inherits:
-
Object
- Object
- Barbeque::DockerImage
- Defined in:
- lib/barbeque/docker_image.rb
Constant Summary collapse
- DEFAULT_TAG =
'latest'
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(str) ⇒ DockerImage
constructor
A new instance of DockerImage.
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ DockerImage
Returns a new instance of DockerImage.
5 6 7 8 9 10 11 |
# File 'lib/barbeque/docker_image.rb', line 5 def initialize(str) # See: https://github.com/docker/docker/blob/v1.10.2/image/spec/v1.md result = str.match(%r{((?<registry>[^/]+)?/)?(?<repository>[\w./-]+)(:(?<tag>[\w.-]+))?\z}) @repository = result[:repository] @tag = result[:tag] || DEFAULT_TAG @registry = result[:registry] || ENV['BARBEQUE_DOCKER_REGISTRY'] end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
13 14 15 |
# File 'lib/barbeque/docker_image.rb', line 13 def registry @registry end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
13 14 15 |
# File 'lib/barbeque/docker_image.rb', line 13 def repository @repository end |
#tag ⇒ Object
Returns the value of attribute tag.
14 15 16 |
# File 'lib/barbeque/docker_image.rb', line 14 def tag @tag end |
Instance Method Details
#to_s ⇒ Object
16 17 18 |
# File 'lib/barbeque/docker_image.rb', line 16 def to_s [registry, "#{repository}:#{tag}"].compact.join('/') end |