Sha256: 917b2712662f86b95ad944aa1ccfecb41f93916d3e5d9bb71ecbd5b724c9cab6

Contents?: true

Size: 793 Bytes

Versions: 40

Compression:

Stored size: 793 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.gsub("\r\n", "\n").split("\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

40 entries across 40 versions & 1 rubygems

Version Path
octopus-serverspec-extensions-0.18.1 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.18.0 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.17.3 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.17.2 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.17.1 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.17.0 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.15.5 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.15.4 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.15.3 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.15.2 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.15.1 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.15.0 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.13.6 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.13.5 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.13.4 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.13.3 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.13.2 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.13.1 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.13.0 lib/octopus_serverspec_extensions/type/chocolatey_package.rb
octopus-serverspec-extensions-0.12.2 lib/octopus_serverspec_extensions/type/chocolatey_package.rb