Class: Aptly::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/aptly/files.rb

Overview

Aptly files management.

Class Method Summary collapse

Class Method Details

.delete(path, connection = Connection.new, **kwords) ⇒ nil

Delete files from remote’s upload directory.

Parameters:

  • path (String)

    path to delete (this may be a directory or a file)

Returns:

  • (nil)


24
25
26
27
# File 'lib/aptly/files.rb', line 24

def delete(path, connection = Connection.new, **kwords)
  connection.send(:delete, "/files/#{path}", kwords)
  nil
end

.upload(files, directory, connection = Connection.new, **kwords) ⇒ Array<String>

Upload files to remote

Parameters:

  • files (Array<String>)

    paths to files to upload

  • directory (String)

    name of the directory to upload to.

  • connection (Connection) (defaults to: Connection.new)

    connection to use

Returns:

  • (Array<String>)

    list of files now on the remote



11
12
13
14
15
16
17
18
19
# File 'lib/aptly/files.rb', line 11

def upload(files, directory, connection = Connection.new, **kwords)
  i = 0
  files.each do |f|
    kwords["file_#{i += 1}".to_sym] = f
  end
  response = connection.send(:post, "/files/#{directory}",
                             kwords)
  JSON.parse(response.body)
end