Class: Natives::HostDetection::PackageProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/natives/host_detection/package_provider.rb

Constant Summary collapse

COMMANDS =
{
  'aix' => 'installp',
  'yum' => 'yum',
  'packman' => 'packman',
  'apt' => 'apt-get',
  'feebsd' => 'pkg_add',
  'portage' => 'emerge',
  'homebrew' => 'brew',
  'macports' => 'port',
  'solaris' => 'pkg_add',
  'ips' => 'pkg',
  'zypper' => 'zypper',
  'smartos' => 'pkgin'
}.freeze
PROVIDERS =
{
  'aix' => 'aix',
  'amazon' => 'yum',
  'arch' => 'pacman',
  'centos' => 'yum',
  'debian' => 'apt',
  'fedora' => 'yum',
  'freebsd' => 'freebsd',
  'gcel' => 'apt',
  'gentoo' => 'portage',
  'linaro' => 'apt',
  'linuxmint' => 'apt',
  'mac_os_x' => ['homebrew', 'macports'],
  'mac_os_x_server' => 'macports',
  'nexentacore' => 'solaris',
  'omnios' => 'ips',
  'openindiana' => 'ips',
  'opensolaris' => 'ips',
  'opensuse' => 'zypper',
  'oracle' => 'yum',
  'raspbian' => 'apt',
  'redhat' => 'yum',
  'scientific' => 'yum',
  'smartos' => 'smartos',
  'solaris2' => 'ips',
  'suse' => 'zypper',
  'ubuntu' => 'apt',
  'xcp' => 'yum',
  'xenserver' => 'yum'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(platform) ⇒ PackageProvider

Returns a new instance of PackageProvider.



50
51
52
# File 'lib/natives/host_detection/package_provider.rb', line 50

def initialize(platform)
  @platform = platform
end

Instance Method Details

#nameObject



54
55
56
57
58
59
60
61
# File 'lib/natives/host_detection/package_provider.rb', line 54

def name
  providers = Array(PROVIDERS[@platform.name])
  return providers.first if providers.count < 2

  providers.find do |provider|
    which(COMMANDS[provider]) != nil
  end
end