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

#content {|tempfile| ... } ⇒ String

Downloads file to specified path. @yieldparam[tempfile Tempfile] Tempfile instance

Yields:

  • (tempfile)

    Access the tempfile from the block parameter

Yield Returns:

  • (nil)

    Tempfile gets closed when the block returns

Returns:

  • (String)

    content of rpm



36
37
38
39
40
# File 'lib/studio_api/rpm.rb', line 36

def content &block
  request = GenericRequest.new self.class.studio_connection
  path = "/rpms/#{id.to_i}/data"
  block_given? ? request.get_file(path, &block) : request.get(path)
end