Class: Serverspec::Type::Package

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/package.rb

Defined Under Namespace

Classes: Version

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#initialize, #inspect, #to_ary, #to_s

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Instance Method Details

#installed?(provider = nil, version = nil) ⇒ Boolean



3
4
5
6
7
8
9
10
11
# File 'lib/serverspec/type/package.rb', line 3

def installed?(provider=nil, version=nil)
  if provider.nil?
    @inspection = Specinfra.command.get(:check_package_is_installed, @name, version)
    @runner.check_package_is_installed(@name, version)
  else
    check_method = "check_package_is_installed_by_#{provider}".to_sym
    @runner.send(check_method, @name, version)
  end
end

#versionObject



13
14
15
16
17
18
19
20
# File 'lib/serverspec/type/package.rb', line 13

def version
  ret = @runner.get_package_version(@name).stdout.strip
  if ret.empty?
    nil
  else
    Version.new(ret)
  end
end