Skip to content

Instantly share code, notes, and snippets.

@colby-swandale
Last active September 16, 2018 11:42
Show Gist options
  • Save colby-swandale/5d842389a76c5a4f5dbc2e4d3a2ad89e to your computer and use it in GitHub Desktop.
Save colby-swandale/5d842389a76c5a4f5dbc2e4d3a2ad89e to your computer and use it in GitHub Desktop.
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?
find_spec_for_exe(name, exec_name, requirements).bin_file exec_name
end
def self.find_spec_for_exe name, exec_name, requirements
dep = Gem::Dependency.new name, requirements
loaded = Gem.loaded_specs[name]
return loaded if loaded && dep.matches_spec?(loaded)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment