Sha256: 9c56bba5fe09ce7815b7d2d1f11ec203e4ec2bcb5fd9fa0a90c04cf2d920c29c
Contents?: true
Size: 942 Bytes
Versions: 27
Compression:
Stored size: 942 Bytes
Contents
# encoding: utf-8 require 'fedux_org_stdlib/core_ext/file/which' module FeduxOrgStdlib class CommandFinder private attr_reader :search_paths, :alternatives public # Finds path to command # # It also considers other executables for one command # # @param [String, Array] alternatives # The executables to be used # # @param [String, Array] search_paths # The search path as multiple paths as array or string where single # search paths are concatenated via ':' def initialize(alternatives:, search_paths:) @alternatives = Array(alternatives) @search_paths = Array(search_paths) end # Find path to command def path alternatives.each do |e| next unless path = File.which(e, search_paths.join(':')) return path end nil end # Return known commands def known_commands @alternatives end end end
Version data entries
27 entries across 27 versions & 1 rubygems