Class: Gitwrap::Repo
- Inherits:
-
GithubConnection
- Object
- GithubConnection
- Gitwrap::Repo
- Defined in:
- lib/gitwrap/repos.rb
Constant Summary
Constants inherited from GithubConnection
Instance Attribute Summary collapse
-
#forks_count ⇒ Object
Returns the value of attribute forks_count.
-
#language ⇒ Object
Returns the value of attribute language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#stars ⇒ Object
Returns the value of attribute stars.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .fetch_all_repos ⇒ Object
- .fetch_org_repos(org) ⇒ Object
- .fetch_single_repo(username, repo) ⇒ Object
- .fetch_user_repos(username) ⇒ Object
Instance Method Summary collapse
-
#initialize(hash) ⇒ Repo
constructor
A new instance of Repo.
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_count ⇒ Object
Returns the value of attribute forks_count.
3 4 5 |
# File 'lib/gitwrap/repos.rb', line 3 def forks_count @forks_count end |
#language ⇒ Object
Returns the value of attribute language.
3 4 5 |
# File 'lib/gitwrap/repos.rb', line 3 def language @language end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/gitwrap/repos.rb', line 3 def name @name end |
#stars ⇒ Object
Returns the value of attribute stars.
3 4 5 |
# File 'lib/gitwrap/repos.rb', line 3 def stars @stars end |
#url ⇒ Object
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_repos ⇒ Object
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 |