Class: GitMulticast::RepositoryFetcher::Github

Inherits:
GitMulticast::RepositoryFetcher show all
Defined in:
lib/git_multicast/repository_fetcher/github.rb

Constant Summary collapse

REPOS_URI =
'https://api.github.com/users/%{username}/repos'

Constants inherited from GitMulticast::RepositoryFetcher

FETCHER_ADAPTER_ZIP

Class Method Summary collapse

Methods inherited from GitMulticast::RepositoryFetcher

adapter_by_url, fetcher_by_url, get_repo_parent, make_struct, zip_by_url

Class Method Details

.get_all_repos_from_user(username) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/git_multicast/repository_fetcher/github.rb', line 9

def self.get_all_repos_from_user(username)
  uri_str = REPOS_URI % { username: username }
  uri = URI(uri_str)

  response = Net::HTTP.get_response(uri)
  repos = JSON.parse(response.body)

  repos.map { |hash| make_struct(hash) }
end

.get_repo(url) ⇒ Object



19
20
21
22
# File 'lib/git_multicast/repository_fetcher/github.rb', line 19

def self.get_repo(url)
  response = Net::HTTP.get_response(URI(url))
  make_struct(JSON.parse(response.body))
end