Class: Gitwrap::Repo

Inherits:
GithubConnection show all
Defined in:
lib/gitwrap/repos.rb

Constant Summary

Constants inherited from GithubConnection

GithubConnection::BASE_URL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Repo

Returns a new instance of Repo.



8
9
10
11
12
13
14
# File 'lib/gitwrap/repos.rb', line 8

def initialize(hash)
	@name = hash["name"]
	@url = hash["url"]
	@forks = hash["forks_count"]
	@language = hash["language"]
	@stars = hash["stargazers_count"]
end

Instance Attribute Details

#forks_countObject

Returns the value of attribute forks_count.



3
4
5
# File 'lib/gitwrap/repos.rb', line 3

def forks_count
  @forks_count
end

#languageObject

Returns the value of attribute language.



3
4
5
# File 'lib/gitwrap/repos.rb', line 3

def language
  @language
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/gitwrap/repos.rb', line 3

def name
  @name
end

#starsObject

Returns the value of attribute stars.



3
4
5
# File 'lib/gitwrap/repos.rb', line 3

def stars
  @stars
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/gitwrap/repos.rb', line 3

def url
  @url
end

Class Method Details

.fetch_all_reposObject



29
30
31
32
33
34
35
# File 'lib/gitwrap/repos.rb', line 29

def self.fetch_all_repos
	data = open("#{BASE_URL}repositories").read()
	data = JSON.parse(data)
	data.each { |repo| $all_repos << new(repo) }
	$current_repo += repos.length-1
	$all_repos
end

.fetch_org_repos(org) ⇒ Object



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

def self.fetch_org_repos(org)
	data = open("#{BASE_URL}orgs/#{org}/repos").read()
	data = JSON.parse(data)
	data.each {|repo| $all_org_repos << new(repo) }
	$all_org_repos
end

.fetch_single_repo(username, repo) ⇒ Object



37
38
39
40
41
# File 'lib/gitwrap/repos.rb', line 37

def self.fetch_single_repo(username, repo)
	data = open("#{BASE_URL}repos/#{username}/#{repo}").read()
	data = JSON.parse(data)
	repo = new(data)
end

.fetch_user_repos(username) ⇒ Object



16
17
18
19
20
# File 'lib/gitwrap/repos.rb', line 16

def self.fetch_user_repos(username)
	data = open("#{BASE_URL}users/#{username}/repos").read()
	data = JSON.parse(data)
	repo = new(data)
end