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 =
'0.9.1'.freeze

Class Method Summary collapse

Class Method Details

.configurationObject



33
34
35
# File 'lib/aptly.rb', line 33

def configuration
  @configuration ||= Configuration.new
end

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

Yields:



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

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



62
63
64
# File 'lib/aptly.rb', line 62

def escape_prefix(prefix_path)
  prefix_path.tr('_', '__').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: '')

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

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

    the source kind (local or snapshot)

Returns:

Raises:



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/aptly.rb', line 43

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