Class: AptlyAPI::Repo

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

Overview

This class represents an Aptly repo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, json) ⇒ Repo

Creates a new Repo definitation with data json located on server



12
13
14
15
16
17
18
19
20
# File 'lib/repo.rb', line 12

def initialize(server, json)
  @server = server
  @http = Net::HTTP.new(@server.host, @server.port)

  @name = json['Name']
  @comment = json['Comment']
  @distrubution = json['DefaultDistribution']
  @component = json['DefaultComponent']
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



49
50
51
# File 'lib/repo.rb', line 49

def comment
  @comment
end

#componentObject (readonly)

Returns the value of attribute component.



49
50
51
# File 'lib/repo.rb', line 49

def component
  @component
end

#distributionObject (readonly)

Returns the value of attribute distribution.



49
50
51
# File 'lib/repo.rb', line 49

def distribution
  @distribution
end

#nameObject (readonly)

Returns the value of attribute name.



49
50
51
# File 'lib/repo.rb', line 49

def name
  @name
end

Instance Method Details

#edit(properties) ⇒ Object

Edit repo properties



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

def edit(properties)
  hput("/api/repos/#{@name}", properties)
end

#import_files(directory, options = {}) ⇒ Object

Import all files uploaded to directory



24
25
26
# File 'lib/repo.rb', line 24

def import_files(directory, options = {})
  hpost("/api/repos/#{@name}/file/#{directory}", options)
end

#packages(query = nil) ⇒ Object

Return a listing of Packages for the repo



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/repo.rb', line 36

def packages(query = nil)
  packages = Array.new
  if !query
    url = "/api/repos/#{@name}/packages"
  else
    url = "/api/repos/#{@name}/packages?q=#{URI.escape(query)}"
  end
  hget(url).each do |key|
    packages.push(Package.new(@server, key))
  end
  packages
end