Class: Zypper::Package

Inherits:
Update
  • Object
show all
Defined in:
lib/zypper/package.rb

Defined Under Namespace

Classes: Status

Constant Summary collapse

PACKAGE_STATUSES =
{
  ''  => Status::AVAILABLE,
  'i' => Status::INSTALLED,
}

Constants inherited from Update

Update::DEFALUT_TYPE, Update::KNOWN_TYPES

Constants included from ZypperUtils

ZypperUtils::ATTRIBUTE_STARTS_WITH, ZypperUtils::PARAMS_FOR_TYPES, ZypperUtils::XML_COMMANDS_GET

Instance Attribute Summary

Attributes included from ZypperUtils

#config, #last_error_message, #last_exit_status, #last_message

Instance Method Summary collapse

Methods inherited from Update

#find_updates

Methods included from ZypperUtils

#initialize

Instance Method Details

#available(options = {}) ⇒ Object

Returns all available packages (that are not installed yet)



61
62
63
# File 'lib/zypper/package.rb', line 61

def available(options = {})
  find(options.merge(:status => Status::AVAILABLE))
end

#find(options = {}) ⇒ Object

Returns packages found using given parameters

Parameters:

  • of (Hash)

    options (string) :name - exact name of a package (symbol) :status - See Zypper::Package::Status class constants



47
48
49
50
51
52
53
# File 'lib/zypper/package.rb', line 47

def find(options = {})
  additional_options = {:cmd_options => ['--type package'], :quiet => true}

  if (run (build_command('search', options.merge(additional_options))))
    convert_packages(last_message)
  end
end

#info(options = {}) ⇒ Object

Returns hash of information on a package given as parameter

(string) :package


30
31
32
33
34
# File 'lib/zypper/package.rb', line 30

def info(options = {})
  if (run(build_command('info', options)))
    convert_info(last_message)
  end
end

#install(options = {}) ⇒ Object

Installs packages given as parmeter

(array) :packages


18
19
20
# File 'lib/zypper/package.rb', line 18

def install(options = {})
  run build_command('install', options)
end

#installed(options = {}) ⇒ Object

Returns all installed packages



56
57
58
# File 'lib/zypper/package.rb', line 56

def installed(options = {})
  find(options.merge(:status => Status::INSTALLED))
end

#installed?(options = {}) ⇒ Boolean

returns whether a package given as parameter is installed

(string) :package

Returns:

  • (Boolean)


38
39
40
# File 'lib/zypper/package.rb', line 38

def installed?(options = {})
  info(options).fetch(Status::INSTALLED, 'No') == 'Yes'
end

#remove(options = {}) ⇒ Object

Removes packages given as parmeter

(array) :packages


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

def remove(options = {})
  run build_command('remove', options)
end

#updates(options = {}) ⇒ Object

Finds all package updates



66
67
68
# File 'lib/zypper/package.rb', line 66

def updates(options = {})
  find_updates(options.merge(:type => :package))
end