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
13
# File 'lib/aptly/publish.rb', line 9

def initialize(*args)
  super(*args)
  # special case for connection being allowed to be nil
  parse_sources if @connection
end

Class Method Details

.from_repositories(repos, prefix, **kwords) ⇒ PublishedRepository

Publish an array of Repository to a prefix.

Parameters:

  • repos (Array<Repository>)

    array of repositories to source

  • prefix (String)

    the prefix to publish under (must be escaped see Aptly.escape_prefix)

Returns:

Since:

  • 0.10.0



52
53
54
55
# File 'lib/aptly/publish.rb', line 52

def from_repositories(repos, prefix, **kwords)
  sources = repos.collect { |x| { Name: x.Name } }
  Aptly.publish(sources, prefix, **kwords)
end

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

List all published repositories.

Returns:



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

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.



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

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



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

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