Class: CheckZilla::Check::Pacman

Inherits:
Object
  • Object
show all
Defined in:
lib/checkzilla/check/pacman.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Pacman

Returns a new instance of Pacman.



11
12
13
14
15
# File 'lib/checkzilla/check/pacman.rb', line 11

def initialize &block
  @results = {}
  instance_eval(&block) if block_given?
  self
end

Instance Attribute Details

#resultsObject

Returns the value of attribute results.



9
10
11
# File 'lib/checkzilla/check/pacman.rb', line 9

def results
  @results
end

Instance Method Details

#perform!Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/checkzilla/check/pacman.rb', line 17

def perform!
  cmd = ''
  cmd = "sudo pacman -Sy > /dev/null ; package-query -AQu -f '%n %l %V'"
  packages = `#{cmd}`.split("\n")
  
  packages.each do |package|
    package_name, package_current_version, package_db_version = package.split(' ')
    @results[package_name] = [package_current_version, package_db_version]
  end
end