Class: Uberinstaller::Commander

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/uberinstaller/commander.rb

Overview

Execute user defined command before and after installation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

configure_logger_for, #logger, logger_for

Constructor Details

#initialize(pkg_name, pkg) ⇒ Commander

Initialize the Commander class with the package information

Parameters:

  • pkg_name (String)

    the name of the package

  • pkg (Hash)

    the content of the package



23
24
25
26
27
28
29
# File 'lib/uberinstaller/commander.rb', line 23

def initialize(pkg_name, pkg)
  @pkg_name = pkg_name
  @pkg = pkg

  @after_cmd_path = File.join Config.command_path, 'after'
  @before_cmd_path = File.join Config.command_path, 'before'
end

Instance Attribute Details

#pkgObject

Returns the value of attribute pkg.



17
18
19
# File 'lib/uberinstaller/commander.rb', line 17

def pkg
  @pkg
end

#pkg_nameObject (readonly)

The name of the package being processed



17
18
19
# File 'lib/uberinstaller/commander.rb', line 17

def pkg_name
  @pkg_name
end

Instance Method Details

#afterObject

Execute after installation command



32
33
34
35
36
37
# File 'lib/uberinstaller/commander.rb', line 32

def after
  if @pkg.has_key? :cmd and @pkg[:cmd].has_key? :after
    logger.info "Executing after commands..."
    run :after
  end
end

#beforeObject

Execute after installation command



40
41
42
43
44
45
# File 'lib/uberinstaller/commander.rb', line 40

def before
  if @pkg.has_key? :cmd and @pkg[:cmd].has_key? :before
    logger.info "Executing before commands..."
    run :before
  end
end