Class: InfinumSetup::Program::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/infinum_setup/program/base.rb

Direct Known Subclasses

Brew, Cask, RubyScript, Script

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#execute, #execute_command, #install_question, #prompt_installing, #prompt_post_install_comment, #prompt_pre_install_comment, #simulate, #skip_install?, #will_install?

Constructor Details

#initialize(name, settings, options) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
# File 'lib/infinum_setup/program/base.rb', line 7

def initialize(name, settings, options)
  @name = name
  @settings = settings
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/infinum_setup/program/base.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/infinum_setup/program/base.rb', line 5

def options
  @options
end

#settingsObject (readonly)

Returns the value of attribute settings.



5
6
7
# File 'lib/infinum_setup/program/base.rb', line 5

def settings
  @settings
end

Instance Method Details

#installObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/infinum_setup/program/base.rb', line 13

def install
  return unless will_install?
  puts
  prompt_pre_install_comment
  return if skip_install?
  prompt_installing
  execute_command
  prompt_post_install_comment
  execute_command(post_install_command) if post_install_command
end

#install_if_not_interactive?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/infinum_setup/program/base.rb', line 40

def install_if_not_interactive?
  settings['install_if_not_interactive']
end

#mandatory?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/infinum_setup/program/base.rb', line 36

def mandatory?
  settings['mandatory']
end

#post_install_commandObject



52
53
54
# File 'lib/infinum_setup/program/base.rb', line 52

def post_install_command
  settings['post_install_command']
end

#post_install_commentObject



48
49
50
# File 'lib/infinum_setup/program/base.rb', line 48

def post_install_comment
  settings['post_install_comment']
end

#pre_install_commentObject



44
45
46
# File 'lib/infinum_setup/program/base.rb', line 44

def pre_install_comment
  settings['pre_install_comment']
end

#valid?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/infinum_setup/program/base.rb', line 31

def valid?
  return true if settings.keys.all? { |key| valid_keys.include?(key.to_sym) }
  raise "#{name} -- Settings are not correct"
end

#valid_keysObject



24
25
26
27
28
29
# File 'lib/infinum_setup/program/base.rb', line 24

def valid_keys
  [
    :mandatory, :pre_install_comment, :post_install_comment, :type,
    :install_if_not_interactive, :post_install_command
  ]
end