class DockerSync::Dependencies::PackageManager::Base
Constants
- DID_NOT_INSTALL_PACKAGE
- FAILED_TO_INSTALL_PACKAGE
Attributes
package[R]
Public Class Methods
install_package(*args)
click to toggle source
# File lib/docker-sync/dependencies/package_managers/base.rb, line 15 def self.install_package(*args) ensure! new(*args).send(:install_package) end
new(package)
click to toggle source
# File lib/docker-sync/dependencies/package_managers/base.rb, line 20 def initialize(package) @package = package end
Private Instance Methods
ask_user_confirmation()
click to toggle source
# File lib/docker-sync/dependencies/package_managers/base.rb, line 33 def ask_user_confirmation raise(DID_NOT_INSTALL_PACKAGE) unless yes?("Install #{package} for you? [y/N]") end
install_cmd()
click to toggle source
# File lib/docker-sync/dependencies/package_managers/base.rb, line 41 def install_cmd raise NotImplementedError end
install_package()
click to toggle source
# File lib/docker-sync/dependencies/package_managers/base.rb, line 26 def install_package say_status 'warning', "Could not find #{package}. Trying to install it now.", :yellow ask_user_confirmation say_status 'command', install_cmd, :white raise(FAILED_TO_INSTALL_PACKAGE) unless perform_installation end
perform_installation()
click to toggle source
# File lib/docker-sync/dependencies/package_managers/base.rb, line 37 def perform_installation Environment.system(install_cmd) end