Sha256: 5f277a187b94321a81f3329b341a84679ffd053bf2428225db1b36b602594186
Contents?: true
Size: 949 Bytes
Versions: 157
Compression:
Stored size: 949 Bytes
Contents
# frozen_string_literal: true require 'eac_ruby_utils/simple_cache' module EacRubyUtils module Envs class Executable include ::EacRubyUtils::SimpleCache attr_reader :env, :name, :check_args def initialize(env, name, *check_args) @env = env @name = name @check_args = check_args end def exist? exist end def validate return nil if exist? "Program \"#{name}\" not found in environment #{env}" end def validate! message = validate raise ProgramNotFoundError, message if message end def command(*command_args) validate! env.command(name, *command_args) end private def exist_uncached env.command(name, *check_args).execute! true rescue Errno::ENOENT false end class ProgramNotFoundError < ::StandardError; end end end end
Version data entries
157 entries across 157 versions & 3 rubygems