Class: Informo::Rpm
- Inherits:
-
Object
- Object
- Informo::Rpm
- Defined in:
- lib/informo/rpm.rb
Overview
This class is used to get information about installed RPMs
Instance Method Summary collapse
-
#get_all(name) ⇒ Object
returns a hash of details for the given package.
-
#get_architecture(name) ⇒ Object
returns the architecture of the given package.
-
#get_description(name) ⇒ Object
returns the
fulldescription of the given package. -
#get_installdate(name) ⇒ Object
returns the installed date of the given package.
-
#get_maintainer(name) ⇒ Object
returns the maintainer of the given package.
-
#get_packages ⇒ Object
returns an array of installed package names.
-
#get_release(name) ⇒ Object
returns the release of the given package.
-
#get_short_description(name) ⇒ Object
returns the
shortdescription (ie: rpm summary field) of the given package. -
#get_status(name) ⇒ Object
returns the status of the installed package (ie. nothing for RPM), kind of a placeholder I guess…
-
#get_version(name) ⇒ Object
returns the version of the given package.
-
#initialize ⇒ Rpm
constructor
A new instance of Rpm.
Constructor Details
#initialize ⇒ Rpm
Returns a new instance of Rpm.
7 8 9 |
# File 'lib/informo/rpm.rb', line 7 def initialize() @@rpmquery = "rpm" end |
Instance Method Details
#get_all(name) ⇒ Object
returns a hash of details for the given package
-
version
-
release
-
architecture
-
maintainer
-
summary
-
description
-
install date
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/informo/rpm.rb', line 74 def get_all(name) results = `#{@@rpmquery} -q --queryformat "%{VERSION}|||%{RELEASE}|||%{ARCH}|||%{VENDOR}|||%{SUMMARY}|||%{DESCRIPTION}|||%{INSTALLTIME:date}" #{name}`.split('|||') # return results as an array and map hresults = {'name' => name, 'version' => results[0], 'release' => results[1], 'architecture' => results[2], 'maintainer' => results[3], 'summary' => results[4], 'description' => results[5], 'installdate' => results[6]} return hresults end |
#get_architecture(name) ⇒ Object
returns the architecture of the given package
31 32 33 34 |
# File 'lib/informo/rpm.rb', line 31 def get_architecture(name) package_architecture = `#{@@rpmquery} -q --qf='%{ARCH}' #{name}` return package_architecture end |
#get_description(name) ⇒ Object
returns the full description of the given package
49 50 51 52 |
# File 'lib/informo/rpm.rb', line 49 def get_description(name) package_description = `#{@@rpmquery} -q --qf='%{DESCRIPTION}' #{name}` return package_description end |
#get_installdate(name) ⇒ Object
returns the installed date of the given package
55 56 57 58 |
# File 'lib/informo/rpm.rb', line 55 def get_installdate(name) package_status = Time.at(Time.parse(`#{@@rpmquery} -q --qf='%{INSTALLTIME:date}' #{name}`)).utc return package_status end |
#get_maintainer(name) ⇒ Object
returns the maintainer of the given package
37 38 39 40 |
# File 'lib/informo/rpm.rb', line 37 def get_maintainer(name) package_maintainer = `#{@@rpmquery} -q --qf='%{VENDOR}' #{name}` return package_maintainer end |
#get_packages ⇒ Object
returns an array of installed package names
12 13 14 15 16 |
# File 'lib/informo/rpm.rb', line 12 def get_packages packages = Array.new packages = `#{@@rpmquery} -qa --qf='%{NAME}\n'`.split("\n") return packages end |
#get_release(name) ⇒ Object
returns the release of the given package
25 26 27 28 |
# File 'lib/informo/rpm.rb', line 25 def get_release(name) package_release = `#{@@rpmquery} -q --qf='%{RELEASE}' #{name}` return package_release end |
#get_short_description(name) ⇒ Object
returns the short description (ie: rpm summary field) of the given package
43 44 45 46 |
# File 'lib/informo/rpm.rb', line 43 def get_short_description(name) package_description = `#{@@rpmquery} -q --qf='%{SUMMARY}' #{name}`.split("\n") return package_description[0] end |
#get_status(name) ⇒ Object
returns the status of the installed package (ie. nothing for RPM), kind of a placeholder I guess…
61 62 63 |
# File 'lib/informo/rpm.rb', line 61 def get_status(name) return end |
#get_version(name) ⇒ Object
returns the version of the given package
19 20 21 22 |
# File 'lib/informo/rpm.rb', line 19 def get_version(name) package_version = `#{@@rpmquery} -q --qf='%{VERSION}' #{name}` return package_version end |