Class: Vain::Github::Repo

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/vain/github.rb

Overview

Get all repositories for a user

Class Method Summary collapse

Class Method Details

.all(user_name) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vain/github.rb', line 25

def self.all(user_name)
  all_repos = []
  page = 1
  begin
    response = RestClient.get("https://api.github.com/users/#{user_name}/repos?page=#{page}", accept: ACCEPT)
    repos = JSON.parse(response)
    all_repos.concat repos.map { |hash| Repo.new(hash) }
    page += 1
  end while repos.size == 30
  all_repos
end