ruby - 使用 Octokit.rb 输出 repos URL

标签 ruby github-api octokit

我正在尝试使用 Octokit.rb 列出 Github 帐户存储库的详细信息,但似乎无法找到关联的 URL。

首先,我需要做的就是使用 OAuth 通过 Github API 进行身份验证,并将详细信息输出到控制台。到目前为止,这是一个基本示例:

client = Octokit::Client.new :access_token => 'my_token'

client.repos.each do |repo|
    puts repo.name
    puts repo.description
    # html_url & clone_url go here.
end

我确定我忽略了一些明显的东西,但是您需要做什么才能找到 html_urlclone_url 等(根据 API )对于每个存储库?

最佳答案

事实证明这是显而易见的:

client = Octokit::Client.new :access_token => 'my_token'

client.repos.each do |repo|
    puts repo.name
    puts repo.description

    # find the urls
    puts repo.rels[:html].href
    puts repo.rels[:git].href
    puts repo.rels[:clone].href
    puts repo.rels[:ssh].href
end

关于ruby - 使用 Octokit.rb 输出 repos URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19742792/

相关文章:

ruby-on-rails - 如何在浏览器中获取表单值以 watir webdriver

github - 如何从 GitHub Api 获取用户的编程语言?

git - 如何使用Github Release API 发布没有源代码的版本?

github - 如何避免使用 API 延迟 github 拉取请求合并

github - 列出所有 Unresolved 拉取请求评论

ruby-on-rails - 如何在闪存错误中添加换行符?

ruby-on-rails - sidekiq 在线程之间共享变量

ruby-on-rails - 从嵌套哈希中删除所有相似的键

jwt - 为什么 id_token 通过带有片段标识符而不是查询字符串的 url 传递?