Class: SysLibDetector::Installer
- Inherits:
-
Object
- Object
- SysLibDetector::Installer
- Defined in:
- lib/sys_lib_detector/installer.rb
Overview
Class responsible for installing the retrieved system libraries
Constant Summary collapse
- AVAILABLE_OS =
Available operating systems for installing the libraries are linux and macos only.
[:linux, :osx]
Instance Method Summary collapse
-
#initialize ⇒ Installer
constructor
Initializing the installer object with the current os.
-
#install(libraries) ⇒ Object
Installing the required system libraries, packager specified according to the current operating system, showing info about the status of the libraries, whether installed or not.
Constructor Details
#initialize ⇒ Installer
Initializing the installer object with the current os
11 12 13 |
# File 'lib/sys_lib_detector/installer.rb', line 11 def initialize @os_name = get_os_name end |
Instance Method Details
#install(libraries) ⇒ Object
Installing the required system libraries, packager specified according to the current operating system, showing info about the status of the libraries, whether installed or not
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sys_lib_detector/installer.rb', line 19 def install(libraries) # Abort with a friendly message if the running OS is not supported yet abort "We're sorry but currently we don't support #{@os_name} package installation" if(!is_os_available?(@os_name)) # Message shown handled by the displayer already abort if libraries.count == 0 installed_libraries = [] failed_libraries = [] libraries.each do |library| installed = self.send("#{@os_name}_installer", library) if(installed == true) installed_libraries << library else failed_libraries << library end end if(failed_libraries.count > 0) abort "#{failed_libraries.count} libraries failed to be installed: #{failed_libraries}" else abort "#{installed_libraries.count} libraries installed successfully!" end end |