Class: Github::Repository
- Inherits:
-
Object
- Object
- Github::Repository
- Includes:
- Base
- Defined in:
- lib/hubdate/repository.rb
Instance Attribute Summary
Attributes included from Base
Class Method Summary collapse
-
.fetch(user, name, conn = Github::Connection.new) ⇒ Object
Generate JSON hash and create new Github::Repository object through Github::Base.
-
.list(login, account_type, params = {}, conn = Github::Connection.new) ⇒ Object
Do some argument checking and then return an array of repository objects.
Methods included from Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Github::Base
Class Method Details
.fetch(user, name, conn = Github::Connection.new) ⇒ Object
Generate JSON hash and create new Github::Repository object through Github::Base
6 7 8 9 10 11 12 |
# File 'lib/hubdate/repository.rb', line 6 def self.fetch(user, name, conn = Github::Connection.new) raise ArgumentError.new("Username must be provided. Call user.repo(*) for an authenticated user's repository.") if user.nil? raise ArgumentError.new("Repository name must be provided.") if name.nil? responseHash = conn.get("/repos/#{user}/#{name}") new(responseHash, conn) end |
.list(login, account_type, params = {}, conn = Github::Connection.new) ⇒ Object
Do some argument checking and then return an array of repository objects
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hubdate/repository.rb', line 15 def self.list(login, account_type, params = {}, conn = Github::Connection.new) conn = params if params.class == Github::Connection params = {} if params.class == Github::Connection case account_type when "User" baseUrl = "users" when "Organization" baseUrl = "orgs" else raise ArgumentError.new("Unknown account type: #{account_type}.") end repositories = conn.get("/#{baseUrl}/#{login}/repos", params) repositories.map do |repo| new(repo, conn) end end |