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



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

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



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

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



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

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



46
47
48
49
# File 'lib/gitwrap/repos.rb', line 46

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



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

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