Module: Aptly

Defined in:
lib/aptly.rb,
lib/aptly/files.rb,
lib/aptly/errors.rb,
lib/aptly/publish.rb,
lib/aptly/tmpname.rb,
lib/aptly/version.rb,
lib/aptly/snapshot.rb,
lib/aptly/connection.rb,
lib/aptly/repository.rb,
lib/aptly/publishable.rb,
lib/aptly/configuration.rb,
lib/aptly/representation.rb

Overview

Aptly API

Defined Under Namespace

Modules: Errors, Publishable Classes: Configuration, Connection, Files, PublishedRepository, Repository, Representation, Snapshot

Constant Summary collapse

VERSION =

The loaded version of the gem.

'0.10.1'.freeze

Class Method Summary collapse

Class Method Details

.configurationObject

The global configuration instance.



35
36
37
# File 'lib/aptly.rb', line 35

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Configures aptly in a block.

Yields:



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

def configure
  yield configuration
end

.escape_prefix(prefix_path) ⇒ String

Translates a pathish prefix (e.g. ‘dev/unstable_x’) to an API-safe prefix (e.g. ‘dev_unstable__x’) See prefix format description on www.aptly.info/doc/api/publish/

Returns:

  • (String)

    API-safe prefix notation

Since:

  • 0.7.0



71
72
73
# File 'lib/aptly.rb', line 71

def escape_prefix(prefix_path)
  prefix_path.gsub('_', '__').tr('/', '_')
end

.publish(sources, prefix = '', source_kind = 'local', connection = Connection.new, **kwords) ⇒ PublishedRepository

Publish 1 or more sources into a public repository prefix.

Parameters:

  • sources (Array<Repository>)

    array of repositories to source

  • prefix (String) (defaults to: '')

    prefix to publish under (i.e. published repo name). This must be escaped (see escape_prefix)

  • source_kind (String) (defaults to: 'local')

    the source kind (local or snapshot)

Returns:

Raises:

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/aptly.rb', line 52

def publish(sources, prefix = '', source_kind = 'local',
            connection = Connection.new, **kwords)
  # TODO: 1.0 break compat and invert the assertion to want unescaped
  raise Errors::InvalidPrefixError if prefix.include?('/')
  kwords = kwords.map { |k, v| [k.to_s.capitalize, v] }.to_h
  options = kwords.merge(
    SourceKind: source_kind,
    Sources: sources
  )
  response = connection.send(:post, "/publish/#{prefix}",
                             body: JSON.generate(options))
  PublishedRepository.new(connection, JSON.parse(response.body))
end

.repo(name, connection = Connection.new, **kwords) ⇒ Object

Convenience shorthand for Aptly::Repository.get.

Since:

  • 0.10.0



41
42
43
# File 'lib/aptly.rb', line 41

def repo(name, connection = Connection.new, **kwords)
  Repository.get(name, connection, **kwords)
end