使用Octokit.rb输出回购URL

Mat*_*don 6 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
Run Code Online (Sandbox Code Playgroud)

我敢肯定,我忽略了一些显而易见的,但你有什么需要做的找html_url,clone_url等(根据API),每个仓库?

Mat*_*don 9

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

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
Run Code Online (Sandbox Code Playgroud)