Class: Gitwrap::Repo

Inherits:
OpenStruct
  • Object
show all
Includes:
HTTParty
Defined in:
lib/gitwrap/repos.rb

Class Method Summary collapse

Class Method Details

.fetch_all_repos(repo_id) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/gitwrap/repos.rb', line 33

def self.fetch_all_repos(repo_id)
  response = get("/repositories?since#{repo_id}")
  if response.success?
    response = response.parsed_response
    response.each {|repo| $repos << new(repo)}
  else
    raise_exception(response.code, response.body)
  end
  $repos
end

.fetch_org_repos(org) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/gitwrap/repos.rb', line 22

def self.fetch_org_repos(org)
  response = get("/orgs/#{org}/repos")
  if response.success?
    response = response.parsed_response
    response.each {|repo| $repos << new(repo)}
  else
    raise_exception(response.code, response.body)
  end
  $repos
end

.fetch_repos_by_language(language) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/gitwrap/repos.rb', line 49

def self.fetch_repos_by_language(language)
  response = get("/search/repositories?q=language:#{language}&sort=stars&order=desc&per_page=100")
  if response.success?
    response = response["items"]
    response.each { |repo| $repos << new(repo)}
  else
    raise_exception(response.code, response.body)
  end
  $repos
end

.fetch_single_repo(username, repo) ⇒ Object



44
45
46
47
# File 'lib/gitwrap/repos.rb', line 44

def self.fetch_single_repo(username, repo)
  response = get("/repos/#{username}/#{repo}")
  if response.success? then repo = new(response) else raise_exception end
end

.fetch_user_repos(username) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gitwrap/repos.rb', line 10

def self.fetch_user_repos(username)
  $repos = []
  response = get("/users/#{username}/repos")
  if response.success?
    response = response.parsed_response
    response.each {|repo| $repos << new(repo)}
  else
    raise_exception(response.code, response.body)
  end
  $repos
end