Class: StudioApi::Rpm

Inherits:
ActiveResource::Base
  • Object
show all
Extended by:
StudioResource
Defined in:
lib/studio_api/rpm.rb

Overview

Represents Additional rpms which can user upload to studio.

Allows uploading, downloading, listing (via find) and deleting

Examples:

Delete own rpm

rpms = StudioApi::Rpm.find :all, :params => { :base_system => "SLE11" }
my_pac = rpms.find {|r| r.filename =~ /my_pac/ }
my_pac.delete

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StudioResource

collection_path, element_path, extended, studio_connection, studio_connection=

Class Method Details

.upload(content, base_system) ⇒ StudioApi::Rpm

Upload file to studio account (user repository)

Parameters:

  • content (String, File)

    of rpm as String or as opened file, in which case name is used as name

  • base_system (#to_s)

    for which is rpm compiled

Returns:



22
23
24
25
26
27
28
29
# File 'lib/studio_api/rpm.rb', line 22

def self.upload content, base_system
  response = GenericRequest.new(studio_connection).post "/rpms?base_system=#{CGI.escape base_system.to_s}", :file => content
  if defined? ActiveModel #for rails3 we need persistent, otherwise delete method fail
    self.new Hash.from_xml(response)["rpm"],true
  else
    self.new Hash.from_xml(response)["rpm"]
  end
end

Instance Method Details

#contentString

Downloads file to specified path.

Returns:

  • (String)

    content of rpm



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

def content
  GenericRequest.new(self.class.studio_connection).get "/rpms/#{id.to_i}/data"
end