Query dependency list from within a rails app

会有一股神秘感。 提交于 2019-12-23 04:53:42

问题


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.

I need the gem name and the version number so something like:

[["actionmailer" "3.1.3"]
 ["coffeescript" "2.0.2"]]

回答1:


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">]


来源:https://stackoverflow.com/questions/9419221/query-dependency-list-from-within-a-rails-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!