Class: Kuby::Docker::Tags

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/kuby/docker/tags.rb

Constant Summary collapse

LATEST =
Metadata::LATEST_TAG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli, remote_client, metadata) ⇒ Tags

Returns a new instance of Tags.



27
28
29
30
31
32
33
34
35
# File 'lib/kuby/docker/tags.rb', line 27

def initialize(cli, remote_client, )
  @cli = cli
  @remote_client = remote_client
  @metadata = 

  @local = T.let(@local, T.nilable(LocalTags))
  @remote = T.let(@remote, T.nilable(RemoteTags))
  @latest_timestamp_tag = T.let(@latest_timestamp_tag, T.nilable(TimestampTag))
end

Instance Attribute Details

#cliObject (readonly)

Returns the value of attribute cli.



11
12
13
# File 'lib/kuby/docker/tags.rb', line 11

def cli
  @cli
end

#metadataObject (readonly)

Returns the value of attribute metadata.



17
18
19
# File 'lib/kuby/docker/tags.rb', line 17

def 
  @metadata
end

#remote_clientObject (readonly)

Returns the value of attribute remote_client.



14
15
16
# File 'lib/kuby/docker/tags.rb', line 14

def remote_client
  @remote_client
end

Instance Method Details

#allObject



77
78
79
# File 'lib/kuby/docker/tags.rb', line 77

def all
  self
end

#latest_tagsObject



43
44
45
# File 'lib/kuby/docker/tags.rb', line 43

def latest_tags
  (local.latest_tags + remote.latest_tags).uniq
end

#latest_timestamp_tagObject



72
73
74
# File 'lib/kuby/docker/tags.rb', line 72

def latest_timestamp_tag
  @latest_timestamp_tag ||= timestamp_tags.sort.last
end

#localObject



82
83
84
# File 'lib/kuby/docker/tags.rb', line 82

def local
  @local ||= LocalTags.new(cli, )
end

#previous_timestamp_tag(current_tag) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/kuby/docker/tags.rb', line 50

def previous_timestamp_tag(current_tag)
  current_tag = TimestampTag.try_parse(current_tag)
  return nil unless current_tag

  all_tags = timestamp_tags.sort

  idx = all_tags.index do |tag|
    tag.time == current_tag.time
  end

  idx ||= 0
  return nil unless idx > 0

  all_tags[idx - 1]
end

#remoteObject



87
88
89
# File 'lib/kuby/docker/tags.rb', line 87

def remote
  @remote ||= RemoteTags.new(remote_client, )
end

#tagsObject



38
39
40
# File 'lib/kuby/docker/tags.rb', line 38

def tags
  (local.tags + remote.tags).uniq
end

#timestamp_tagsObject



67
68
69
# File 'lib/kuby/docker/tags.rb', line 67

def timestamp_tags
  (local.timestamp_tags + remote.timestamp_tags).uniq
end