Class: ContainerRegistry::Blob

Inherits:
Object
  • Object
show all
Defined in:
lib/container_registry/blob.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, config) ⇒ Blob

Returns a new instance of Blob.


9
10
11
12
# File 'lib/container_registry/blob.rb', line 9

def initialize(repository, config)
  @repository = repository
  @config = config || {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


5
6
7
# File 'lib/container_registry/blob.rb', line 5

def config
  @config
end

#repositoryObject (readonly)

Returns the value of attribute repository


5
6
7
# File 'lib/container_registry/blob.rb', line 5

def repository
  @repository
end

Instance Method Details

#dataObject


46
47
48
# File 'lib/container_registry/blob.rb', line 46

def data
  @data ||= client.blob(repository.path, digest, type)
end

#deleteObject


42
43
44
# File 'lib/container_registry/blob.rb', line 42

def delete
  client.delete_blob(repository.path, digest)
end

#digestObject


22
23
24
# File 'lib/container_registry/blob.rb', line 22

def digest
  config['digest'] || config['blobSum']
end

#pathObject


18
19
20
# File 'lib/container_registry/blob.rb', line 18

def path
  "#{repository.path}@#{digest}"
end

#revisionObject


34
35
36
# File 'lib/container_registry/blob.rb', line 34

def revision
  digest.split(':')[1]
end

#short_revisionObject


38
39
40
# File 'lib/container_registry/blob.rb', line 38

def short_revision
  revision[0..8]
end

#sizeObject


30
31
32
# File 'lib/container_registry/blob.rb', line 30

def size
  config['size']
end

#typeObject


26
27
28
# File 'lib/container_registry/blob.rb', line 26

def type
  config['mediaType']
end

#valid?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/container_registry/blob.rb', line 14

def valid?
  digest.present?
end