Class: GitHubApi
- Inherits:
-
Object
- Object
- GitHubApi
- Defined in:
- lib/chid/github_api.rb
Overview
Api Reference: developer.github.com/v3/search/#search-repositories
Defined Under Namespace
Classes: Owner, Repository
Class Method Summary collapse
Class Method Details
.repositories(search_expression) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chid/github_api.rb', line 29 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 |