Sha256: 909083780e3f25f80e1399aacbc04397f91868d004f5dff932a7d2c57f600329
Contents?: true
Size: 1.31 KB
Versions: 17
Compression:
Stored size: 1.31 KB
Contents
require 'forwardable' module DockerSync module Dependencies module PackageManager class Base DID_NOT_INSTALL_PACKAGE = 'Did not install required package. Please install it manually and try again.'.freeze FAILED_TO_INSTALL_PACKAGE = 'Failed to install required package. Please install it manually and try again.'.freeze extend Forwardable def_delegators :"Thor::Shell::Color.new", :say_status, :yes? attr_reader :package def self.install_package(*args) ensure! new(*args).send(:install_package) end def initialize(package) @package = package end private 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 def ask_user_confirmation raise(DID_NOT_INSTALL_PACKAGE) unless yes?("Install #{package} for you? [y/N]") end def perform_installation defined?(Bundler) ? Bundler.clean_system(install_cmd) : system(install_cmd) end def install_cmd raise NotImplementedError end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems