Class: Github::Repository

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/hubdate/repository.rb

Instance Attribute Summary

Attributes included from Base

#connection, #response

Class Method Summary collapse

Methods included from Base

#initialize, #method_missing

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

Raises:

  • (ArgumentError)


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(, , params = {}, conn = Github::Connection.new)
  conn = params if params.class == Github::Connection
  params = {} if params.class == Github::Connection

  case 
  when "User"
    baseUrl = "users"
  when "Organization"
    baseUrl = "orgs"
  else
    raise ArgumentError.new("Unknown account type: #{}.")
  end

  repositories = conn.get("/#{baseUrl}/#{}/repos", params)

  repositories.map do |repo|
    new(repo, conn)
  end
end