Class: Aptly::PublishedRepository
- Inherits:
-
Representation
- Object
- OpenStruct
- Representation
- Aptly::PublishedRepository
- 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
Class Method Summary collapse
-
.from_repositories(repos, prefix, **kwords) ⇒ PublishedRepository
Publish an array of Repository to a prefix.
-
.list(connection = Connection.new, **kwords) ⇒ Array<PublishedRepository>
List all published repositories.
Instance Method Summary collapse
-
#drop(**kwords) ⇒ Object
Drops a published repository.
-
#initialize(*args) ⇒ PublishedRepository
constructor
A new instance of PublishedRepository.
-
#update!(**kwords) ⇒ self?
Update this published repository using new contents of Sources.
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.
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.
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
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 |