Output a repos URLs using Octokit.rb
Asked Answered
A

1

6

I'm attempting to list details of a Github accounts repos using Octokit.rb, but can't seem to find the associated URLs.

In the first instance all I need to do is authenticate with the Github API using OAuth and output the details to the console. Here's a basic example so far:

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

I'm sure I've overlooked something obvious, but what do you need to do to find the html_url, clone_url etc (as per the API) for each repository?

Alacrity answered 2/11, 2013 at 14:13 Comment(0)
A
8

Turns out it was obvious after all:

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
Alacrity answered 2/11, 2013 at 16:15 Comment(1)
How do you know that you have to put ".href" at the end? Is is in the API documentation?Dummy

© 2022 - 2024 — McMap. All rights reserved.