class ConvoxInstaller::Requirements
Attributes
ecr_label[RW]
logger[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/convox_installer/requirements.rb, line 11 def initialize(options = {}) @ecr_label = options[:ecr_label] @logger = Logger.new(STDOUT) logger.level = options[:log_level] || Logger::INFO end
Public Instance Methods
ensure_requirements!()
click to toggle source
# File lib/convox_installer/requirements.rb, line 17 def ensure_requirements! logger.debug "Checking for required commands..." @missing_packages = [] unless has_command? "convox" @missing_packages << { name: "convox", brew: "convox", docs: "https://docs.convox.com/introduction/installation", } end unless has_command? "aws" @missing_packages << { name: "aws", brew: "awscli", docs: "https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html", } end if @missing_packages.any? logger.error "This script requires the convox and AWS CLI tools." if OS.mac? logger.error "Please run: brew install " \ "#{@missing_packages.map { |p| p[:brew] }.join(" ")}" else logger.error "Installation Instructions:" @missing_packages.each do |package| logger.error "* #{package[:name]}: #{package[:docs]}" end end quit! end end
find_command(command)
click to toggle source
Stubbed in tests
# File lib/convox_installer/requirements.rb, line 63 def find_command(command) `which #{command} 2>/dev/null`.chomp end
has_command?(command)
click to toggle source
# File lib/convox_installer/requirements.rb, line 52 def has_command?(command) path = find_command command if path.present? logger.debug "=> Found #{command}: #{path}" return true end logger.debug "=> Could not find #{command}!" false end
quit!()
click to toggle source
# File lib/convox_installer/requirements.rb, line 67 def quit! exit 1 end