本文介绍了从Rails应用程序中查询依赖列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从运行rails应用程序有一种方法来枚举应用程序的依赖关系列表?假设我无法访问Gemfile或Gemfile.lock文件。
From a running rails app is there a way to enumerate the list of dependencies for the application? Assume I don't have access to the Gemfile or Gemfile.lock files.
我需要gem名称和版本号,例如:
I need the gem name and the version number so something like:
[["actionmailer" "3.1.3"]
["coffeescript" "2.0.2"]]
推荐答案
假设您应该使用bundler,您可以像这样访问它:
Assuming bundler, which you should use, you can access it like this:
Bundler.environment.current_dependencies
#=> [<Bundler::Dependency type=:development name="minitest" requirements=">= 2.11.0">,
<Bundler::Dependency type=:development name="rspec-expectations" requirements=">= 2.7.0">,
<Bundler::Dependency type=:development name="mocha" requirements=">= 0.10.0">,
<Bundler::Dependency type=:development name="cucumber" requirements=">= 1.1.4">]
这篇关于从Rails应用程序中查询依赖列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!