使用捆绑程序以编程方式确定gem的路径 [英] Programmatically determine gem's path using bundler
本文介绍了使用捆绑程序以编程方式确定gem的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道你可以做
bundle show gem_name
显示某些宝石的路径。
如何使用Bundler对象在代码中执行此操作?
How do you do that from within the code using the Bundler object?
推荐答案
看看他们如何在 cli.rb
def locate_gem(name)
spec = Bundler.load.specs.find{|s| s.name == name }
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
if spec.name == 'bundler'
return File.expand_path('../../../', __FILE__)
end
spec.full_gem_path
end
这篇关于使用捆绑程序以编程方式确定gem的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文