github_api 0.14.5 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/github_api/client/git_data/references.rb +1 -1
- data/lib/github_api/client/git_data/tags.rb +1 -2
- data/lib/github_api/client/pull_requests.rb +6 -3
- data/lib/github_api/client/pull_requests/comments.rb +1 -1
- data/lib/github_api/client/pull_requests/reviews.rb +156 -0
- data/lib/github_api/client/repos.rb +18 -11
- data/lib/github_api/response/mashify.rb +1 -0
- data/lib/github_api/version.rb +1 -1
- metadata +27 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9312a6593c2f32bcc8b408beca9259a0747a70be
|
4
|
+
data.tar.gz: 9d5e113c5690642ef9fb0d9269ccc42d54421bd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15f1895fc1e726e678f67298e0489c681da59b2e0737c4baba47baa74dfe998ac8d76e0bd02f6f9bdf304fb8043694f70c15e77b670427d1cafa2cb2db4c35cb
|
7
|
+
data.tar.gz: e4e76f0e15c2ad51905fca1d8072072c689f8a80758e3f86b26bf8004e66fb58bea975393345dc8852d9bcfca495ae2bd195261f075b6cbbd5188087f2124c72
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
<div align="center">
|
2
2
|
<a href="http://piotrmurach.github.io/github/"><img width="136" src="https://github.com/piotrmurach/github/raw/master/icons/github_api.png" alt="github api logo" /></a>
|
3
3
|
</div>
|
4
|
+
|
4
5
|
# GithubAPI
|
6
|
+
|
5
7
|
[][gem]
|
6
8
|
[][travis]
|
7
9
|
[][codeclimate]
|
@@ -4,6 +4,7 @@ module Github
|
|
4
4
|
class Client::GitData::Tags < API
|
5
5
|
# This tags api only deals with tag objects -
|
6
6
|
# so only annotated tags, not lightweight tags.
|
7
|
+
# Refer https://developer.github.com/v3/git/tags/#parameters
|
7
8
|
|
8
9
|
VALID_TAG_PARAM_NAMES = %w[
|
9
10
|
tag
|
@@ -13,8 +14,6 @@ module Github
|
|
13
14
|
name
|
14
15
|
email
|
15
16
|
date
|
16
|
-
sha
|
17
|
-
url
|
18
17
|
tagger
|
19
18
|
].freeze
|
20
19
|
|
@@ -3,10 +3,12 @@
|
|
3
3
|
module Github
|
4
4
|
class Client::PullRequests < API
|
5
5
|
|
6
|
-
require_all 'github_api/client/pull_requests', 'comments'
|
6
|
+
require_all 'github_api/client/pull_requests', 'comments', 'reviews'
|
7
7
|
|
8
8
|
# Access to PullRequests::Comments API
|
9
9
|
namespace :comments
|
10
|
+
# Access to PullRequests::Reviews API
|
11
|
+
namespace :reviews
|
10
12
|
|
11
13
|
# List pull requests
|
12
14
|
#
|
@@ -171,8 +173,9 @@ module Github
|
|
171
173
|
# Optional string - The message that will be used for the merge commit
|
172
174
|
# @option params [String] :sha
|
173
175
|
# Optional string - The SHA that pull request head must match to allow merge
|
174
|
-
# @option params [
|
175
|
-
# Optional
|
176
|
+
# @option params [String] :merge_method
|
177
|
+
# Optional string - Merge method to use.
|
178
|
+
# Valid values are merge, squash, and rebase. Default is merge.
|
176
179
|
#
|
177
180
|
# @example
|
178
181
|
# github = Github.new
|
@@ -58,7 +58,7 @@ module Github
|
|
58
58
|
def get(*args)
|
59
59
|
arguments(args, required: [:user, :repo, :number])
|
60
60
|
|
61
|
-
get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls
|
61
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/comments", arguments.params)
|
62
62
|
end
|
63
63
|
alias_method :find, :get
|
64
64
|
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
class Client::PullRequests::Reviews < API
|
5
|
+
PREVIEW_MEDIA = "application/vnd.github.black-cat-preview+json".freeze # :nodoc:
|
6
|
+
|
7
|
+
# List reviews on a pull request
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# github = Github.new
|
11
|
+
# github.pull_requests.reviews.list 'user-name', 'repo-name', number: 'pull-request-number'
|
12
|
+
#
|
13
|
+
# List pull request reviews in a repository
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# github = Github.new
|
17
|
+
# github.pull_requests.reviews.list 'user-name', 'repo-name', number: 'pull-request-number'
|
18
|
+
# github.pull_requests.reviews.list 'user-name', 'repo-name', number: 'pull-request-number' { |comm| ... }
|
19
|
+
#
|
20
|
+
# @api public
|
21
|
+
def list(*args)
|
22
|
+
arguments(args, required: [:user, :repo, :number])
|
23
|
+
params = arguments.params
|
24
|
+
|
25
|
+
params["accept"] ||= PREVIEW_MEDIA
|
26
|
+
|
27
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews", params)
|
28
|
+
return response unless block_given?
|
29
|
+
response.each { |el| yield el }
|
30
|
+
end
|
31
|
+
alias_method :all, :list
|
32
|
+
|
33
|
+
# Get a single review for pull requests
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# github = Github.new
|
37
|
+
# github.pull_requests.reviews.get 'user-name', 'repo-name', 'number', 'id'
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# github.pull_requests.reviews.get
|
41
|
+
# user: 'user-name',
|
42
|
+
# repo: 'repo-name',
|
43
|
+
# number: 1,
|
44
|
+
# id: 80
|
45
|
+
#
|
46
|
+
# @api public
|
47
|
+
def get(*args)
|
48
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
49
|
+
|
50
|
+
params = arguments.params
|
51
|
+
params["accept"] ||= PREVIEW_MEDIA
|
52
|
+
|
53
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}", params)
|
54
|
+
end
|
55
|
+
alias_method :find, :get
|
56
|
+
|
57
|
+
# Create a pull request review
|
58
|
+
#
|
59
|
+
# @param [Hash] params
|
60
|
+
# @option params [String] :event
|
61
|
+
# Required string - The review action (event) to perform; can be one of
|
62
|
+
# APPROVE, REQUEST_CHANGES, or COMMENT. If left blank, the API returns
|
63
|
+
# HTTP 422 (Unrecognizable entity) and the review is left PENDING
|
64
|
+
# @option params [String] :body
|
65
|
+
# Optional string. The text of the review.
|
66
|
+
# @option params [Array] :comments
|
67
|
+
# Optional array of draft review comment objects. An array of comments
|
68
|
+
# part of the review.
|
69
|
+
#
|
70
|
+
# @example
|
71
|
+
# github = Github.new
|
72
|
+
# github.pull_requests.reviews.create 'user-name', 'repo-name', 'number',
|
73
|
+
# body: "Nice change",
|
74
|
+
# event: "APPROVE",
|
75
|
+
# comments: [
|
76
|
+
# {
|
77
|
+
# path: 'path/to/file/commented/on',
|
78
|
+
# position: 10,
|
79
|
+
# body: 'This looks good.'
|
80
|
+
# }
|
81
|
+
# ]
|
82
|
+
#
|
83
|
+
# @api public
|
84
|
+
def create(*args)
|
85
|
+
arguments(args, required: [:user, :repo, :number])
|
86
|
+
|
87
|
+
params = arguments.params
|
88
|
+
params["accept"] ||= PREVIEW_MEDIA
|
89
|
+
|
90
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews", params)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Update a pull request review
|
94
|
+
#
|
95
|
+
# @param [Hash] params
|
96
|
+
# @option params [String] :state
|
97
|
+
# Required string - The review action (event) to perform; can be one of
|
98
|
+
# APPROVE, REQUEST_CHANGES, or COMMENT. If left blank, the API returns
|
99
|
+
# HTTP 422 (Unrecognizable entity) and the review is left PENDING
|
100
|
+
# @optoin params [String] :body
|
101
|
+
# Optional string
|
102
|
+
#
|
103
|
+
# @example
|
104
|
+
# github = Github.new oauth_token: '...'
|
105
|
+
# github.pull_requests.reviews.update 'user-name', 'repo-name', 'number', 'review-id'
|
106
|
+
# body: "Update body",
|
107
|
+
# event: "APPROVE"
|
108
|
+
#
|
109
|
+
# @api public
|
110
|
+
def update(*args)
|
111
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
112
|
+
params = arguments.params
|
113
|
+
|
114
|
+
params["accept"] ||= PREVIEW_MEDIA
|
115
|
+
|
116
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/events", params)
|
117
|
+
end
|
118
|
+
|
119
|
+
# @option params [String] :message
|
120
|
+
# Optional string - Reason for dismissal
|
121
|
+
#
|
122
|
+
# @example
|
123
|
+
# github = Github.new oauth_token: '...'
|
124
|
+
# github.pull_requests.reviews.dismiss 'user-name', 'repo-name', 'number', 'review-id'
|
125
|
+
# message: "I can't get to this right now."
|
126
|
+
#
|
127
|
+
# @api public
|
128
|
+
def dismiss(*args)
|
129
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
130
|
+
params = arguments.params
|
131
|
+
|
132
|
+
params["accept"] ||= PREVIEW_MEDIA
|
133
|
+
|
134
|
+
put_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/dismissals", params)
|
135
|
+
end
|
136
|
+
|
137
|
+
# List comments on a pull request review
|
138
|
+
#
|
139
|
+
# @example
|
140
|
+
# github = Github.new
|
141
|
+
# github.pull_requests.revieiws.comments 'user-name', 'repo-name', 'number', 'review-id'
|
142
|
+
#
|
143
|
+
# @api public
|
144
|
+
def comments(*args)
|
145
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
146
|
+
params = arguments.params
|
147
|
+
|
148
|
+
params["accept"] ||= PREVIEW_MEDIA
|
149
|
+
|
150
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/comments", params)
|
151
|
+
return response unless block_given?
|
152
|
+
response.each { |el| yield el }
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
end
|
@@ -20,14 +20,6 @@ module Github
|
|
20
20
|
'statistics',
|
21
21
|
'statuses'
|
22
22
|
|
23
|
-
DEFAULT_REPO_OPTIONS = {
|
24
|
-
"homepage" => "https://github.com",
|
25
|
-
"private" => false,
|
26
|
-
"has_issues" => true,
|
27
|
-
"has_wiki" => true,
|
28
|
-
"has_downloads" => true
|
29
|
-
}.freeze
|
30
|
-
|
31
23
|
REQUIRED_REPO_OPTIONS = %w[ name ]
|
32
24
|
|
33
25
|
VALID_REPO_OPTIONS = %w[
|
@@ -166,6 +158,21 @@ module Github
|
|
166
158
|
end
|
167
159
|
alias :find :get
|
168
160
|
|
161
|
+
# Get a repository
|
162
|
+
#
|
163
|
+
# @example
|
164
|
+
# github = Github.new
|
165
|
+
# github.repos.get_by_id 'repo-id'
|
166
|
+
# github.repos.get_by_id id: 'repo-id'
|
167
|
+
# github.repos(id: 'repo-id').get_by_id
|
168
|
+
#
|
169
|
+
def get_by_id(*args)
|
170
|
+
arguments(args, required: [:id])
|
171
|
+
|
172
|
+
get_request("/repositories/#{arguments.id}", arguments.params)
|
173
|
+
end
|
174
|
+
alias :find_by_id :get_by_id
|
175
|
+
|
169
176
|
# Create a new repository for the autheticated user.
|
170
177
|
#
|
171
178
|
# @param [Hash] params
|
@@ -229,9 +236,9 @@ module Github
|
|
229
236
|
|
230
237
|
# Requires authenticated user
|
231
238
|
if (org = params.delete('org') || org)
|
232
|
-
post_request("/orgs/#{org}/repos", params
|
239
|
+
post_request("/orgs/#{org}/repos", params)
|
233
240
|
else
|
234
|
-
post_request(
|
241
|
+
post_request("/user/repos", params)
|
235
242
|
end
|
236
243
|
end
|
237
244
|
|
@@ -313,7 +320,7 @@ module Github
|
|
313
320
|
assert_required %w[ name ]
|
314
321
|
end
|
315
322
|
|
316
|
-
patch_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params
|
323
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
|
317
324
|
end
|
318
325
|
|
319
326
|
# Delete a repository
|
data/lib/github_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -86,6 +86,26 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 0.0.4
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: mime-types
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.16'
|
96
|
+
- - "<"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '3.0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.16'
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.0'
|
89
109
|
- !ruby/object:Gem::Dependency
|
90
110
|
name: bundler
|
91
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,16 +124,16 @@ dependencies:
|
|
104
124
|
name: rake
|
105
125
|
requirement: !ruby/object:Gem::Requirement
|
106
126
|
requirements:
|
107
|
-
- - "
|
127
|
+
- - "<"
|
108
128
|
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
129
|
+
version: '11.0'
|
110
130
|
type: :development
|
111
131
|
prerelease: false
|
112
132
|
version_requirements: !ruby/object:Gem::Requirement
|
113
133
|
requirements:
|
114
|
-
- - "
|
134
|
+
- - "<"
|
115
135
|
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
136
|
+
version: '11.0'
|
117
137
|
description: " Ruby client that supports all of the GitHub API methods. It's build
|
118
138
|
in a modular way, that is, you can either instantiate the whole api wrapper Github.new
|
119
139
|
or use parts of it e.i. Github::Client::Repos.new if working solely with repositories
|
@@ -170,6 +190,7 @@ files:
|
|
170
190
|
- lib/github_api/client/orgs/teams.rb
|
171
191
|
- lib/github_api/client/pull_requests.rb
|
172
192
|
- lib/github_api/client/pull_requests/comments.rb
|
193
|
+
- lib/github_api/client/pull_requests/reviews.rb
|
173
194
|
- lib/github_api/client/repos.rb
|
174
195
|
- lib/github_api/client/repos/collaborators.rb
|
175
196
|
- lib/github_api/client/repos/comments.rb
|