class Tagfish::DockerURI

Constants

URI_PARSER

Attributes

protocol[RW]
registry[RW]
repository[RW]
tag[RW]

Public Class Methods

new(protocol, registry, repository, tag) click to toggle source
# File lib/tagfish/docker_uri.rb, line 23
def initialize(protocol, registry, repository, tag)
  @protocol = protocol
  @registry = registry
  @repository = repository
  @tag = tag

  if registry.nil?
    @protocol = "https://"
    @registry = "index.docker.io"
  elsif protocol.nil?
    @protocol = "https://"
  end
end
parse(docker_string) click to toggle source
# File lib/tagfish/docker_uri.rb, line 13
def self.parse(docker_string)
  match = docker_string.match(URI_PARSER)
  new(*match.captures)
end

Public Instance Methods

repo_and_tag() click to toggle source
# File lib/tagfish/docker_uri.rb, line 37
def repo_and_tag
  tag.nil? ? "#{repository}" : "#{repository}:#{tag}"
end
tag?() click to toggle source
# File lib/tagfish/docker_uri.rb, line 41
def tag?
  not tag.nil?
end
tagged_latest?() click to toggle source
# File lib/tagfish/docker_uri.rb, line 45
def tagged_latest?
  tag == 'latest'
end
to_s() click to toggle source
# File lib/tagfish/docker_uri.rb, line 53
def to_s
  reg_sep = registry.nil? ? nil : "/"
  tag_sep = tag.nil? ? nil : ":"
  if registry == "index.docker.io"
    "#{repository}#{tag_sep}#{tag}"
  else
    "#{registry}#{reg_sep}#{repository}#{tag_sep}#{tag}"
  end
end
with_tag(new_tag) click to toggle source
# File lib/tagfish/docker_uri.rb, line 49
def with_tag(new_tag)
  self.class.new(protocol, registry, repository, new_tag)
end