class GitHubApi

Api Reference: developer.github.com/v3/search/#search-repositories

Constants

Owner
Repository

Public Class Methods

prs(by:) click to toggle source
# File lib/chid/github_api.rb, line 29
def self.prs(by:)
  owner     = 'rachidcalazans'
  repo_name = 'chid'
  uri = URI("https://api.github.com/repos/#{owner}/#{repo_name}/pulls")
  request = ::HTTP.get(uri)

  JSON.parse request
end
repositories(search_expression) click to toggle source
# File lib/chid/github_api.rb, line 38
def self.repositories(search_expression)
    uri = URI("https://api.github.com/search/repositories?q=#{search_expression}&sort=stars&order=desc")
    request = ::HTTP.get(uri)
    json_repositories = JSON.parse request

    json_repositories['items'].collect do |item|
      updated_at = item['updated_at'].nil? ? nil : Date.parse(item['updated_at'])
      owner = Owner.new(item['owner']['login'])
      Repository.new(item['name'], owner, item['html_url'], item['clone_url'], item['language'],
                      item['stargazers_count'], updated_at)
    end
end