Sha256: 59982b04033c56697c99c00f3ec41b00b6e3175ece6fd9cc47ef8fc8b90a0dc5

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

require 'serverspec'
require 'serverspec/type/base'

module Serverspec::Type
  class ChocolateyPackage < Base

    def initialize(name)
      @name = name
      @runner = Specinfra::Runner
    end

    def installed?(provider, version)
      command_result = @runner.run_command("choco list -l -r #{name}")

      software = command_result.stdout.split("\r\n").each_with_object({}) do |s, h|
        v, k = s.split('|')
        h[String(v).strip.downcase] = String(k).strip.downcase
        h
      end

      if (version.nil?)
        !software[name.downcase].nil?
      else
        software[name.downcase] == version
      end
    end
  end

  def chocolatey_package(name)
    ChocolateyPackage.new(name)
  end
end

include Serverspec::Type

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
octopus-serverspec-extensions-0.6.0 lib/octopus_serverspec_extensions/type/chocolatey_package.rb