Class: Aptly::PublishedRepository

Inherits:
Representation show all
Defined in:
lib/aptly/publish.rb

Overview

A published repository representation. Published repositories are not Repository instances as they are in fact comprised of one or more different repositories.

Instance Attribute Summary

Attributes inherited from Representation

#connection

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PublishedRepository

Returns a new instance of PublishedRepository.



9
10
11
12
# File 'lib/aptly/publish.rb', line 9

def initialize(*args)
  super(*args)
  parse_sources
end

Class Method Details

.list(connection = Connection.new, **kwords) ⇒ Array<PublishedRepository>

List all published repositories.

Returns:



38
39
40
41
42
43
# File 'lib/aptly/publish.rb', line 38

def list(connection = Connection.new, **kwords)
  kwords = kwords.map { |k, v| [k.to_s.capitalize, v] }.to_h
  response = connection.send(:get, '/publish',
                             query: kwords)
  JSON.parse(response.body).collect { |h| new(connection, h) }
end

Instance Method Details

#drop(**kwords) ⇒ Object

Drops a published repository. This removes the published repository but leaves its soures intact.



16
17
18
19
# File 'lib/aptly/publish.rb', line 16

def drop(**kwords)
  connection.send(:delete, "/publish/#{self.Storage}:#{api_prefix}/#{self.Distribution}",
                  query: kwords)
end

#update!(**kwords) ⇒ self?

Note:

this possibly mutates the attributes depending on the HTTP response

Update this published repository using new contents of Sources

Returns:

  • (self)

    if the instance data was mutated

  • (nil)

    if the instance data was not mutated



25
26
27
28
29
30
31
32
33
# File 'lib/aptly/publish.rb', line 25

def update!(**kwords)
  response = connection.send(:put,
                             "/publish/#{self.Storage}:#{api_prefix}/#{self.Distribution}",
                             body: JSON.generate(kwords))
  hash = JSON.parse(response.body, symbolize_names: true)
  return nil if hash == marshal_dump
  marshal_load(hash)
  self
end