Class: Mixlib::Install::Options

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

Defined Under Namespace

Classes: InvalidOptions

Constant Summary collapse

OMNITRUCK_CHANNELS =
[:stable, :current]
ARTIFACTORY_CHANNELS =
[:unstable]
ALL_SUPPORTED_CHANNELS =
OMNITRUCK_CHANNELS + ARTIFACTORY_CHANNELS
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,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Options

Returns a new instance of Options.



45
46
47
48
49
# File 'lib/mixlib/install/options.rb', line 45

def initialize(options)
  @options = options

  validate!
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#for_artifactory?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/mixlib/install/options.rb', line 73

def for_artifactory?
  ARTIFACTORY_CHANNELS.include?(channel)
end

#for_bintray?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/mixlib/install/options.rb', line 77

def for_bintray?
  [:stable, :current].include?(channel)
end

#for_omnitruck?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/mixlib/install/options.rb', line 81

def for_omnitruck?
  OMNITRUCK_CHANNELS.include?(channel)
end

#for_ps1?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/mixlib/install/options.rb', line 85

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

#latest_version?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/mixlib/install/options.rb', line 89

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


98
99
100
101
102
103
104
# File 'lib/mixlib/install/options.rb', line 98

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

  validate_options!
end

#validate!Object



51
52
53
# File 'lib/mixlib/install/options.rb', line 51

def validate!
  validate_options!
end

#validate_options!Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/mixlib/install/options.rb', line 55

def validate_options!
  errors = []

  errors << validate_product_names
  errors << validate_channels
  errors << validate_shell_type

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