Class: Mixlib::Install::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/mixlib/install/options.rb

Defined Under Namespace

Classes: InvalidOptions

Constant Summary collapse

SUPPORTED_ARCHITECTURES =
%w{
  i386
  powerpc
  ppc64
  ppc64le
  s390x
  sparc
  x86_64
}
SUPPORTED_CHANNELS =
[
  :stable,
  :current,
  :unstable,
]
SUPPORTED_PRODUCT_NAMES =
PRODUCT_MATRIX.products
SUPPORTED_SHELL_TYPES =
[
  :ps1,
  :sh,
]
SUPPORTED_OPTIONS =
[
  :architecture,
  :channel,
  :platform,
  :platform_version,
  :product_name,
  :product_version,
  :shell_type,
  :platform_version_compatibility_mode,
  :include_metadata,
  :user_agent_headers,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Options

Returns a new instance of Options.



62
63
64
65
66
67
68
# File 'lib/mixlib/install/options.rb', line 62

def initialize(options)
  @options = options

  map_windows_desktop_versions! if for_windows?

  validate!
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



28
29
30
# File 'lib/mixlib/install/options.rb', line 28

def options
  @options
end

Instance Method Details

#for_ps1?Boolean Also known as: for_windows?

Returns:

  • (Boolean)


94
95
96
# File 'lib/mixlib/install/options.rb', line 94

def for_ps1?
  platform == "windows" || shell_type == :ps1
end

#include_metadata?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/mixlib/install/options.rb', line 103

def include_metadata?
  .to_s == "true"
end

#latest_version?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/mixlib/install/options.rb', line 99

def latest_version?
  product_version.to_sym == :latest
end

#set_platform_info(info) ⇒ Object

Set the platform info on the instance info [Hash]

Hash with keys :platform, :platform_version and :architecture


112
113
114
115
116
117
118
# File 'lib/mixlib/install/options.rb', line 112

def set_platform_info(info)
  options[:platform] = info[:platform]
  options[:platform_version] = info[:platform_version]
  options[:architecture] = info[:architecture]

  validate_options!
end

#validate!Object



70
71
72
# File 'lib/mixlib/install/options.rb', line 70

def validate!
  validate_options!
end

#validate_options!Object



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/mixlib/install/options.rb', line 74

def validate_options!
  errors = []

  errors << validate_architecture
  errors << validate_product_names
  errors << validate_channels
  errors << validate_shell_type
  errors << validate_user_agent_headers

  unless errors.compact.empty?
    raise InvalidOptions, errors.join("\n")
  end
end