gpt4 book ai didi

ruby-on-rails - 如何获取 Gemfiles 中所有 gems 的 Github repo 位置?

转载 作者:数据小太阳 更新时间:2023-10-29 08:57:41 26 4
gpt4 key购买 nike

我有一个包含 gem 列表的 Gemfile,即:

gem 'celluloid'
gem 'typhoeus'

有没有办法一次性获取所有这些 Gems 的 Github 存储库 URL 列表,而无需我手动查找它们?也许使用 bundle ?

IE,我想得到这个返回:

https://github.com/celluloid/celluloid
https://github.com/typhoeus/typhoeus

最佳答案

一个 gem 可能一个公共(public)的 github 仓库...它可能是一个私有(private)仓库,或者存储在不同的主机上,甚至根本不在线。因此无法保证您能够将每个 gem 映射到 github 存储库。

但是,您可以尝试解决一些问题,例如:

  • 首先,找到 gemspec。它可以是本地 ( gem spec <name> ) 或远程 ( gem spec -r <name> )。
  • 解析上述 YAML。
  • 检查每个 gemspec 主页。
  • 检查每个 gemspec 描述。
  • 如果上述方法失败,请尝试直接搜索 github - 例如与 Octokit .
  • 处理特殊边缘情况,例如 ActionCablerails 内存储库。

这显然是一项不平凡的任务......不过值得庆幸的是,这个库已经处理了很多艰巨的工作:

https://github.com/teeparham/gemdiff

用法:

> gem install gemdiff

> gemdiff find celluloid
> https://github.com/celluloid/celluloid

> gemdiff find typhoeus
> https://github.com/typhoeus/typhoeus

> gemdiff find notarealgem12321
> ERROR: No gem matching 'notarealgem12321 (>= 0)' found
> Could not find github repository for notarealgem12321

关于ruby-on-rails - 如何获取 Gemfiles 中所有 gems 的 Github repo 位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46199300/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com