Class: Kitchen::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/platform.rb

Overview

A target operating system environment in which convergence integration will take place. This may represent a specific operating system, version, and machine architecture.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Platform

Constructs a new platform.

Parameters:

  • options (Hash) (defaults to: {})

    configuration for a new platform

Options Hash (options):

  • :name (String)

    logical name of this platform (Required)



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/kitchen/platform.rb', line 40

def initialize(options = {})
  @name = options.fetch(:name) do
    raise ClientError, "Platform#new requires option :name"
  end
  @os_type = options.fetch(:os_type) do
    windows?(options) ? "windows" : "unix"
  end
  @shell_type = options.fetch(:shell_type) do
    windows?(options) ? "powershell" : "bourne"
  end
end

Instance Attribute Details

#nameString (readonly)

Returns logical name of this platform.

Returns:

  • (String)

    logical name of this platform



27
28
29
# File 'lib/kitchen/platform.rb', line 27

def name
  @name
end

#os_typeString (readonly)

Returns operating system type hint (default: ‘“unix”`).

Returns:

  • (String)

    operating system type hint (default: ‘“unix”`)



30
31
32
# File 'lib/kitchen/platform.rb', line 30

def os_type
  @os_type
end

#shell_typeString (readonly)

Returns shell command flavor hint (default: ‘“bourne”`).

Returns:

  • (String)

    shell command flavor hint (default: ‘“bourne”`)



33
34
35
# File 'lib/kitchen/platform.rb', line 33

def shell_type
  @shell_type
end

Instance Method Details

#diagnoseHash

Returns a Hash of configuration and other useful diagnostic information.

Returns:

  • (Hash)

    a diagnostic hash



61
62
63
# File 'lib/kitchen/platform.rb', line 61

def diagnose
  { os_type: os_type, shell_type: shell_type }
end

#windows?(options) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/kitchen/platform.rb', line 52

def windows?(options)
  @name.downcase =~ /^win/ || (
    !options[:transport].nil? && options[:transport][:name] == "winrm"
  )
end