Class: PullReq

Inherits:
Object
  • Object
show all
Defined in:
lib/github/pullreqs/pullreqs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(github) ⇒ PullReq

Returns a new instance of PullReq.



4
5
6
7
# File 'lib/github/pullreqs/pullreqs.rb', line 4

def initialize(github)
  @github = github
  @reviewcomments = PullReviewComments.new(github)
end

Instance Attribute Details

#githubObject

Returns the value of attribute github.



2
3
4
# File 'lib/github/pullreqs/pullreqs.rb', line 2

def github
  @github
end

#reviewcommentsObject

Returns the value of attribute reviewcomments.



2
3
4
# File 'lib/github/pullreqs/pullreqs.rb', line 2

def reviewcomments
  @reviewcomments
end

Instance Method Details

#createPullRequest(repo, title, base, head, body = nil, user = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/github/pullreqs/pullreqs.rb', line 22

def createPullRequest(repo, title, base, head, body=nil, user=nil)
  username = user == nil ? @github.username : user
  params = {
      :title => title,
      :base => base,
      :head => head,
      :body => body
  }
  params = @github.removeEmptyParams(params)
  data = params.to_json
  @github.post('repos/%s/%s/pulls' % [username, repo], data)
end

#createPullRequestFromIssue(repo, issue, base, head, user = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/github/pullreqs/pullreqs.rb', line 35

def createPullRequestFromIssue(repo, issue, base, head, user=nil)
  username = user == nil ? @github.username : user
  params = {
      :issue => issue,
      :base => base,
      :head => head
  }
  data = params.to_json
  @github.post('repos/%s/%s/pulls' % [username, repo], data)
end

#getIfPullRequestMerged(repo, id, user = nil) ⇒ Object



58
59
60
61
62
# File 'lib/github/pullreqs/pullreqs.rb', line 58

def getIfPullRequestMerged(repo, id, user=nil)
  username = user == nil ? @github.username : user
  @github.get(
      'repos/%s/%s/pulls/%s/merge' % [username, repo, id])
end

#getPullRequest(repo, id, user = nil) ⇒ Object



16
17
18
19
20
# File 'lib/github/pullreqs/pullreqs.rb', line 16

def getPullRequest(repo, id, user=nil)
  username = user == nil ? @github.username : user
  @github.get(
      'repos/%s/%s/pulls/%s' % [username, repo, id])
end

#listPullRequestCommits(repo, id, user = nil) ⇒ Object



46
47
48
49
50
# File 'lib/github/pullreqs/pullreqs.rb', line 46

def listPullRequestCommits(repo, id, user=nil)
  username = user == nil ? @github.username : user
  @github.get(
      'repos/%s/%s/pulls/%s/commits' % [username, repo, id])
end

#listPullRequestFiles(repo, id, user = nil) ⇒ Object



52
53
54
55
56
# File 'lib/github/pullreqs/pullreqs.rb', line 52

def listPullRequestFiles(repo, id, user=nil)
  username = user == nil ? @github.username : user
  @github.get(
      'repos/%s/%s/pulls/%s/files' % [username, repo, id])
end

#listPullRequests(repo, state = nil, user = nil) ⇒ Object



9
10
11
12
13
14
# File 'lib/github/pullreqs/pullreqs.rb', line 9

def listPullRequests(repo, state=nil, user=nil)
  username = user == nil ? @github.username : user
  url = 'repos/%s/%s/pulls' % [username, repo]
  url = '%s?%s' % state ? [url, @github.parameterize(state)] : url
  @github.get(url)
end

#mergePullRequest(repo, id, commit_message = nil, user = nil) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/github/pullreqs/pullreqs.rb', line 64

def mergePullRequest(repo, id, commit_message=nil, user=nil)
  username = user == nil ? @github.username : user
  if commit_message
    params = {
        :commit_message => commit_message
    }
    data = params.to_json
    @github.put('repos/%s/%s/pulls/%s/merge' % [username, repo, id], data)
  else
    @github.put('repos/%s/%s/pulls/%s/merge' % [username, repo, id])
  end
end