Class: Ghee::API::Repos::Proxy

Inherits:
ResourceProxy show all
Defined in:
lib/ghee/api/keys.rb,
lib/ghee/api/forks.rb,
lib/ghee/api/hooks.rb,
lib/ghee/api/pulls.rb,
lib/ghee/api/repos.rb,
lib/ghee/api/issues.rb,
lib/ghee/api/issues.rb,
lib/ghee/api/labels.rb,
lib/ghee/api/commits.rb,
lib/ghee/api/contents.rb,
lib/ghee/api/git_data.rb,
lib/ghee/api/watchers.rb,
lib/ghee/api/milestones.rb,
lib/ghee/api/collaborators.rb,
lib/ghee/api/commit_comments.rb

Overview

Repos::Proxy inherits from Ghee::Proxy and enables defining methods on the proxy object

Instance Attribute Summary collapse

Attributes inherited from ResourceProxy

#connection, #current_page, #id, #pagination, #params, #path_prefix, #total

Instance Method Summary collapse

Methods inherited from ResourceProxy

accept_header, #all, #all_parallel, #build_prefix, #initialize, #method_missing, #paginate, #raw, #subject

Methods included from CUD

#create, #destroy, #patch

Constructor Details

This class inherits a constructor from Ghee::ResourceProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ghee::ResourceProxy

Instance Attribute Details

#repo_nameObject

Returns the value of attribute repo_name.



17
18
19
# File 'lib/ghee/api/repos.rb', line 17

def repo_name
  @repo_name
end

Instance Method Details

#assigneesObject



18
19
20
21
# File 'lib/ghee/api/issues.rb', line 18

def assignees
    prefix = "#{path_prefix}/assignees"
    Ghee::API::Repos::Assignees::Proxy.new(connection, prefix)
end

#collaborators(user = nil, &block) ⇒ Object



29
30
31
32
# File 'lib/ghee/api/collaborators.rb', line 29

def collaborators(user=nil, &block)
  prefix = build_prefix user, "collaborators"
  Collaborators::Proxy.new(connection, prefix, user, &block)
end

#comments(id = nil, &block) ⇒ Object



14
15
16
17
# File 'lib/ghee/api/commit_comments.rb', line 14

def comments(id=nil, &block)
  prefix = build_prefix id, "comments"
  Ghee::API::Repos::Commits::Comments::Proxy.new connection, prefix, id, &block
end

#commits(sha = nil, &block) ⇒ Object



20
21
22
23
# File 'lib/ghee/api/commits.rb', line 20

def commits(sha=nil, &block)
  prefix = build_prefix sha, "commits"
  Ghee::API::Repos::Commits::Proxy.new(connection, prefix, sha, &block)
end

#compare(base, head) ⇒ Object



17
18
19
# File 'lib/ghee/api/commits.rb', line 17

def compare(base, head)
  connection.get("#{path_prefix}/compare/#{base}...#{head}").body
end

#contents(path, &block) ⇒ Object



36
37
38
39
40
# File 'lib/ghee/api/contents.rb', line 36

def contents(path, &block)
  proxy = Contents::Proxy.new connection, "#{path_prefix}/contents/#{path}", nil, &block
  proxy.path = path
  proxy
end

#forks(params = {}) ⇒ Object



26
27
28
# File 'lib/ghee/api/forks.rb', line 26

def forks(params={})
  Ghee::API::Repos::Forks::Proxy.new connection, "#{path_prefix}/forks", params
end

#gitObject



102
103
104
# File 'lib/ghee/api/git_data.rb', line 102

def git
  Ghee::API::Repos::Git::Proxy.new(connection, "#{path_prefix}/git")
end

#hooks(number = nil, params = {}) ⇒ Object

Get hooks

Returns json



37
38
39
40
41
# File 'lib/ghee/api/hooks.rb', line 37

def hooks(number=nil, params={})
  params = number if number.is_a?Hash
  prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/hooks/#{number}" : "#{path_prefix}/hooks"
  Ghee::API::Repos::Hooks::Proxy.new(connection, prefix, params)
end

#issues(number = nil, &block) ⇒ Object

Get issues

Returns json



175
176
177
178
179
180
# File 'lib/ghee/api/issues.rb', line 175

def issues(number=nil, &block)
  prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/issues/#{number}" : "#{path_prefix}/issues"
  issue = Ghee::API::Repos::Issues::Proxy.new(connection, prefix, number, &block)
  issue.repo = self
  issue
end

#keys(id = nil) ⇒ Object



24
25
26
27
# File 'lib/ghee/api/keys.rb', line 24

def keys(id=nil)
  prefix = id ? "#{path_prefix}/keys/#{id}" : "#{path_prefix}/keys"
  Ghee::API::Repos::Keys::Proxy.new connection, prefix
end

#labels(number = nil, params = {}) ⇒ Object

Get labels for a repo

id - Number get a specific label (optional)

Returns json



29
30
31
32
33
# File 'lib/ghee/api/labels.rb', line 29

def labels(number=nil, params={})
  params = number if number.is_a?Hash
  prefix = (!number.is_a?(Hash) and number)  ? "#{path_prefix}/labels/#{number}" : "#{path_prefix}/labels"
  Ghee::API::Repos::Labels::Proxy.new(connection, prefix, params)
end

#milestones(number = nil, params = {}) ⇒ Object

Get milestones

Returns json



55
56
57
58
59
# File 'lib/ghee/api/milestones.rb', line 55

def milestones(number=nil, params={})
  params = number if number.is_a?Hash
  prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/milestones/#{number}" : "#{path_prefix}/milestones"
  Ghee::API::Repos::Milestones::Proxy.new(connection, prefix, params)
end

#pulls(number = nil, params = {}) ⇒ Object



40
41
42
43
44
# File 'lib/ghee/api/pulls.rb', line 40

def pulls(number=nil, params={})
  params = number if number.is_a?Hash
  prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/pulls/#{number}" : "#{path_prefix}/pulls"
  Ghee::API::Repos::Pulls::Proxy.new(connection, prefix, params)
end

#readme(&block) ⇒ Object



41
42
43
# File 'lib/ghee/api/contents.rb', line 41

def readme(&block)
  Contents::Proxy.new connection, "#{path_prefix}/readme", {}, &block
end

#watchersObject



18
19
20
# File 'lib/ghee/api/watchers.rb', line 18

def watchers
  connection.get("#{path_prefix}/watchers").body
end