Class: RightConf::PackageInstaller
- Inherits:
-
Object
- Object
- RightConf::PackageInstaller
- Includes:
- ProgressReporter, Singleton
- Defined in:
- lib/rconf/support/package_installer.rb
Instance Method Summary collapse
-
#install(packages, opts = nil, &install_check) ⇒ Object
Install given packages.
Methods included from ProgressReporter
included, report_to_file, report_to_stdout
Methods included from Singleton
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
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
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rconf/support/package_installer.rb', line 36 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 end true end |