Sha256: 9fe29b82d294c46d7fb9543ab1f56a55973ad688eeab0d11f6315c036834e06f

Contents?: true

Size: 592 Bytes

Versions: 6

Compression:

Stored size: 592 Bytes

Contents

Ohai.plugin(:PkgManager) do
  provides 'pkg_manager'

  def return_version(cmd)
    out = shell_out("#{cmd} || true")
    value out.stdout.strip
    value.match(/(\d+\.)(\d+\.)(\d+)/)
  end

  collect_data(:linux) do
    pkg_manager Mash.new

    # HACK: it may be a better way to collect the default pkg manages
    DEFAULT_PKG_MANAGES = [
      'pacman',
      'dpkg',
      'apt',
      'gem',
      'pip',
      'pip3',
    ]

    DEFAULT_PKG_MANAGES.each do |manager|
      pkg_manager[manager] = {
        "version" => return_version("#{manager} --version")
      }
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cupper-0.2.1 lib/cupper/plugins/ohai/pkg_manager.rb
cupper-0.2.0 lib/cupper/plugins/ohai/pkg_manager.rb
cupper-0.1.3 lib/cupper/plugins/ohai/pkg_manager.rb
cupper-0.1.2 lib/cupper/plugins/ohai/pkg_manager.rb
cupper-0.1.1 lib/cupper/plugins/ohai/pkg_manager.rb
cupper-0.1.0 lib/cupper/plugins/ohai/pkg_manager.rb