Find the full path to the executable for gem
name. If the exec_name is not given, the gem’s
default_executable is chosen, otherwise the specified executable’s path is returned. requirements
allows you to specify specific gem versions.
# File lib/rubygems.rb, line 297
def self.bin_path(name, exec_name = nil, *requirements)
# TODO: fails test_self_bin_path_bin_file_gone_in_latest
# Gem::Specification.find_by_name(name, *requirements).bin_file exec_name
raise ArgumentError, "you must supply exec_name" unless exec_name
requirements = Gem::Requirement.default if
requirements.empty?
specs = Gem::Dependency.new(name, requirements).matching_specs(true)
raise Gem::GemNotFoundException,
"can't find gem #{name} (#{requirements})" if specs.empty?
specs = specs.find_all { |spec|
spec.executables.include? exec_name
} if exec_name
unless spec = specs.last
msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}"
raise Gem::GemNotFoundException, msg
end
spec.bin_file exec_name
end