Class: RightConf::PackageInstaller

Inherits:
Object
  • Object
show all
Includes:
ProgressReporter, Singleton
Defined in:
lib/rconf/support/package_installer.rb

Instance Method Summary collapse

Methods included from ProgressReporter

included, report_to_file, report_to_stdout

Methods included from Singleton

included

Instance Method Details

#install(packages, opts = nil, &install_check) ⇒ Object

Install given packages

Parameters

packages(String|Array)

Package name or Packages list

opts(String)

Optional, abort configuration

and display given error message if install fails when set
opts(TrueClass|FalseClass)

Whether to report installation

opts(String)

Message displayed only when software was installed

Block

If a block is given it will get called with no argument prior to the packages being installed. If the block returns true then installation will proceed otherwise it won’t. Use the block to check whether installation is required or whether the packages are already installed. If no block is given then installation will always occur.

Return

true

Always return true



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rconf/support/package_installer.rb', line 37

def install(packages, opts=nil, &install_check)
  packages = [ packages ].flatten.compact
  return true if packages.empty?
  report = opts && opts.delete(:report)
  must_install = true
  if install_check
    report_check("Checking for #{packages.join(', ')}") if report
    must_install = install_check.call
    report_result(must_install) if report
  end
  if must_install
    report_check("Installing #{packages.join(', ')}") if report
    Platform.dispatch(packages, opts) { :install }
    report_success if report
    opts && opts[:post_install] && report('Note: '.blue + opts[:post_install])
  end
  true
end