github_api 0.12.4 → 0.13.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 +9 -8
- data/lib/github_api/api/arguments.rb +2 -2
- data/lib/github_api/client/authorizations.rb +28 -31
- data/lib/github_api/client/authorizations/app.rb +1 -3
- data/lib/github_api/client/orgs.rb +42 -23
- data/lib/github_api/client/orgs/members.rb +37 -21
- data/lib/github_api/client/orgs/memberships.rb +129 -0
- data/lib/github_api/client/orgs/teams.rb +157 -43
- data/lib/github_api/client/repos/commits.rb +2 -2
- data/lib/github_api/client/repos/keys.rb +35 -14
- data/lib/github_api/client/repos/releases.rb +57 -23
- data/lib/github_api/client/repos/releases/tags.rb +22 -0
- data/lib/github_api/configuration.rb +1 -1
- data/lib/github_api/validations/required.rb +5 -10
- data/lib/github_api/version.rb +1 -8
- metadata +4 -2
@@ -19,7 +19,7 @@ module Github
|
|
19
19
|
# @option params [String] :path
|
20
20
|
# Only commits containing this file path will be returned.
|
21
21
|
# @option params [String] :author
|
22
|
-
# GitHub login, name
|
22
|
+
# GitHub login, name or email by which to filter by commit author.
|
23
23
|
# @option params [String] :since
|
24
24
|
# Only commits after this date will be returned. This is a timestamp
|
25
25
|
# in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
@@ -48,7 +48,7 @@ module Github
|
|
48
48
|
#
|
49
49
|
# @example
|
50
50
|
# github = Github.new
|
51
|
-
# github.repos.commits.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6'
|
51
|
+
# github.repos.commits.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6'
|
52
52
|
#
|
53
53
|
# @api public
|
54
54
|
def get(*args)
|
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
module Github
|
4
4
|
class Client::Repos::Keys < API
|
5
|
-
|
6
|
-
VALID_KEY_OPTIONS = %w[ title key ].freeze
|
7
|
-
|
8
5
|
# List deploy keys
|
9
6
|
#
|
7
|
+
# @see https://developer.github.com/v3/repos/keys/#list
|
8
|
+
#
|
9
|
+
# @param [String] :user
|
10
|
+
# @param [String :repo
|
11
|
+
#
|
10
12
|
# @example
|
11
13
|
# github = Github.new
|
12
14
|
# github.repos.keys.list 'user-name', 'repo-name'
|
@@ -20,33 +22,47 @@ module Github
|
|
20
22
|
def list(*args)
|
21
23
|
arguments(args, required: [:user, :repo])
|
22
24
|
|
23
|
-
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
|
25
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
|
26
|
+
arguments.params)
|
24
27
|
return response unless block_given?
|
25
28
|
response.each { |el| yield el }
|
26
29
|
end
|
27
|
-
|
30
|
+
alias_method :all, :list
|
28
31
|
|
29
32
|
# Get a key
|
30
33
|
#
|
34
|
+
# @see https://developer.github.com/v3/repos/keys/#get
|
35
|
+
#
|
36
|
+
# @param [String] :user
|
37
|
+
# @param [String] :repo
|
38
|
+
# @param [Integer] :id
|
39
|
+
#
|
31
40
|
# @example
|
32
41
|
# github = Github.new
|
33
42
|
# github.repos.keys.get 'user-name', 'repo-name', 'key-id'
|
34
43
|
#
|
35
44
|
# @api public
|
36
45
|
def get(*args)
|
37
|
-
arguments(args, :
|
46
|
+
arguments(args, required: [:user, :repo, :id])
|
38
47
|
|
39
48
|
get_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", arguments.params)
|
40
49
|
end
|
41
|
-
|
50
|
+
alias_method :find, :get
|
42
51
|
|
43
52
|
# Create a key
|
44
53
|
#
|
54
|
+
# @see https://developer.github.com/v3/repos/keys/#create
|
55
|
+
#
|
56
|
+
# @param [String] :user
|
57
|
+
# @param [String] :repo
|
45
58
|
# @param [Hash] params
|
46
59
|
# @option params [String] :title
|
47
60
|
# Required string.
|
48
61
|
# @option params [String] :key
|
49
62
|
# Required string.
|
63
|
+
# @option params [String] :read_only
|
64
|
+
# If true, the key will only be able to read repository contents.
|
65
|
+
# Otherwise, the key will be able to read and write.
|
50
66
|
#
|
51
67
|
# @example
|
52
68
|
# github = Github.new
|
@@ -56,16 +72,21 @@ module Github
|
|
56
72
|
#
|
57
73
|
# @api public
|
58
74
|
def create(*args)
|
59
|
-
arguments(args, required: [:user, :repo])
|
60
|
-
permit VALID_KEY_OPTIONS
|
61
|
-
assert_required VALID_KEY_OPTIONS
|
62
|
-
end
|
75
|
+
arguments(args, required: [:user, :repo])
|
63
76
|
|
64
|
-
post_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
|
77
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
|
78
|
+
arguments.params)
|
65
79
|
end
|
80
|
+
alias_method :add, :create
|
66
81
|
|
67
82
|
# Delete key
|
68
83
|
#
|
84
|
+
# @see https://developer.github.com/v3/repos/keys/#delete
|
85
|
+
#
|
86
|
+
# @param [String] :user
|
87
|
+
# @param [String] :repo
|
88
|
+
# @param [Integer] :id
|
89
|
+
#
|
69
90
|
# @example
|
70
91
|
# github = Github.new
|
71
92
|
# github.repos.keys.delete 'user-name', 'repo-name', 'key-id'
|
@@ -73,9 +94,9 @@ module Github
|
|
73
94
|
# @api public
|
74
95
|
def delete(*args)
|
75
96
|
arguments(args, required: [:user, :repo, :id])
|
76
|
-
params = arguments.params
|
77
97
|
|
78
|
-
delete_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", params)
|
98
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", arguments.params)
|
79
99
|
end
|
100
|
+
alias_method :remove, :delete
|
80
101
|
end # Client::Repos::Keys
|
81
102
|
end # Github
|
@@ -4,26 +4,22 @@ module Github
|
|
4
4
|
# The Releases API
|
5
5
|
class Client::Repos::Releases < API
|
6
6
|
|
7
|
-
require_all 'github_api/client/repos/releases', 'assets'
|
8
|
-
|
9
|
-
VALID_RELEASE_PARAM_NAMES = %w[
|
10
|
-
tag_name
|
11
|
-
target_commitish
|
12
|
-
name
|
13
|
-
body
|
14
|
-
draft
|
15
|
-
prerelease
|
16
|
-
].freeze # :nodoc:
|
7
|
+
require_all 'github_api/client/repos/releases', 'assets', 'tags'
|
17
8
|
|
18
9
|
# Access to Repos::Releases::Assets API
|
19
10
|
namespace :assets
|
20
11
|
|
12
|
+
# Access to Repos::Releases::Tags API
|
13
|
+
namespace :tags
|
14
|
+
|
21
15
|
# List releases for a repository
|
22
16
|
#
|
23
17
|
# Users with push access to the repository will receive all releases
|
24
18
|
# (i.e., published releases and draft releases). Users with pull access
|
25
19
|
# will receive published releases only.
|
26
20
|
#
|
21
|
+
# @see https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
|
22
|
+
#
|
27
23
|
# @example
|
28
24
|
# github = Github.new
|
29
25
|
# github.repos.releases.list 'owner', 'repo'
|
@@ -31,16 +27,18 @@ module Github
|
|
31
27
|
#
|
32
28
|
# @api public
|
33
29
|
def list(*args)
|
34
|
-
arguments(args, required: [:owner, :repo])
|
30
|
+
arguments(args, required: [:owner, :repo])
|
35
31
|
|
36
32
|
response = get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases", arguments.params)
|
37
33
|
return response unless block_given?
|
38
34
|
response.each { |el| yield el }
|
39
35
|
end
|
40
|
-
|
36
|
+
alias_method :all, :list
|
41
37
|
|
42
38
|
# Get a single release
|
43
39
|
#
|
40
|
+
# @see https://developer.github.com/v3/repos/releases/#get-a-single-release
|
41
|
+
#
|
44
42
|
# @example
|
45
43
|
# github = Github.new
|
46
44
|
# github.repos.releases.get 'owner', 'repo', 'id'
|
@@ -48,12 +46,17 @@ module Github
|
|
48
46
|
# @api public
|
49
47
|
def get(*args)
|
50
48
|
arguments(args, required: [:owner, :repo, :id]).params
|
49
|
+
|
51
50
|
get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}" , arguments.params)
|
52
51
|
end
|
53
|
-
|
52
|
+
alias_method :find, :get
|
54
53
|
|
55
54
|
# Create a release
|
56
55
|
#
|
56
|
+
# Users with push access to the repository can create a release.
|
57
|
+
#
|
58
|
+
# @see https://developer.github.com/v3/repos/releases/#create-a-release
|
59
|
+
#
|
57
60
|
# @param [Hash] params
|
58
61
|
# @input params [String] :tag_name
|
59
62
|
# Required. The name of the tag.
|
@@ -75,7 +78,7 @@ module Github
|
|
75
78
|
#
|
76
79
|
# @example
|
77
80
|
# github = Github.new
|
78
|
-
# github.repos.releases.create 'owner', 'repo',
|
81
|
+
# github.repos.releases.create 'owner', 'repo',
|
79
82
|
# tag_name: "v1.0.0",
|
80
83
|
# target_commitish: "master",
|
81
84
|
# name: "v1.0.0",
|
@@ -85,17 +88,23 @@ module Github
|
|
85
88
|
#
|
86
89
|
# @api public
|
87
90
|
def create(*args)
|
88
|
-
arguments(args, required: [:owner, :repo
|
89
|
-
|
91
|
+
arguments(args, required: [:owner, :repo]) do
|
92
|
+
assert_required :tag_name
|
90
93
|
end
|
91
|
-
params = arguments.params
|
92
|
-
params['tag_name'] = arguments.tag_name
|
93
94
|
|
94
|
-
post_request("/repos/#{arguments.owner}/#{arguments.repo}/releases",
|
95
|
+
post_request("/repos/#{arguments.owner}/#{arguments.repo}/releases",
|
96
|
+
arguments.params)
|
95
97
|
end
|
96
98
|
|
97
99
|
# Edit a release
|
98
100
|
#
|
101
|
+
# Users with push access to the repository can edit a release.
|
102
|
+
#
|
103
|
+
# @see https://developer.github.com/v3/repos/releases/#edit-a-release
|
104
|
+
#
|
105
|
+
# @param [String] :owner
|
106
|
+
# @param [String] :repo
|
107
|
+
# @param [Integer] :id
|
99
108
|
# @param [Hash] params
|
100
109
|
# @input params [String] :tag_name
|
101
110
|
# Required. The name of the tag.
|
@@ -127,18 +136,22 @@ module Github
|
|
127
136
|
#
|
128
137
|
# @api public
|
129
138
|
def edit(*args)
|
130
|
-
arguments(args, required: [:owner, :repo, :id])
|
131
|
-
permit VALID_RELEASE_PARAM_NAMES
|
132
|
-
end
|
139
|
+
arguments(args, required: [:owner, :repo, :id])
|
133
140
|
|
134
141
|
patch_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}", arguments.params)
|
135
142
|
end
|
136
|
-
|
143
|
+
alias_method :update, :edit
|
137
144
|
|
138
145
|
# Delete a release
|
139
146
|
#
|
140
147
|
# Users with push access to the repository can delete a release.
|
141
148
|
#
|
149
|
+
# @see https://developer.github.com/v3/repos/releases/#delete-a-release
|
150
|
+
#
|
151
|
+
# @param [String] :owner
|
152
|
+
# @param [String] :repo
|
153
|
+
# @param [Integer] :id
|
154
|
+
#
|
142
155
|
# @example
|
143
156
|
# github = Github.new
|
144
157
|
# github.repos.releases.delete 'owner', 'repo', 'id'
|
@@ -149,5 +162,26 @@ module Github
|
|
149
162
|
|
150
163
|
delete_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}", arguments.params)
|
151
164
|
end
|
165
|
+
|
166
|
+
# Get the latest release
|
167
|
+
#
|
168
|
+
# View the latest published full release for the repository.
|
169
|
+
# Draft releases and prereleases are not returned.
|
170
|
+
#
|
171
|
+
# @see https://developer.github.com/v3/repos/releases/#get-the-latest-release
|
172
|
+
#
|
173
|
+
# @param [String] :owner
|
174
|
+
# @param [String] :repo
|
175
|
+
#
|
176
|
+
# @example
|
177
|
+
# github = Github.new
|
178
|
+
# github.repos.releases.latest 'owner', 'repo'
|
179
|
+
#
|
180
|
+
# @api public
|
181
|
+
def latest(*args)
|
182
|
+
arguments(args, required: [:owner, :repo]).params
|
183
|
+
|
184
|
+
get_request("repos/#{arguments.owner}/#{arguments.repo}/releases/latest", arguments.params)
|
185
|
+
end
|
152
186
|
end # Client::Repos::Statuses
|
153
187
|
end # Github
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
# The Releases API
|
5
|
+
class Client::Repos::Releases::Tags < API
|
6
|
+
# Get a published release with the specified tag.
|
7
|
+
#
|
8
|
+
# @see https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# github = Github.new
|
12
|
+
# github.repos.releases.tags.get 'owner', 'repo', 'tag'
|
13
|
+
#
|
14
|
+
# @api public
|
15
|
+
def get(*args)
|
16
|
+
arguments(args, required: [:owner, :repo, :tag]).params
|
17
|
+
|
18
|
+
get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/tags/#{arguments.tag}" , arguments.params)
|
19
|
+
end
|
20
|
+
alias_method :find, :get
|
21
|
+
end # Client::Repos::Releases::Tags
|
22
|
+
end # Github
|
@@ -39,7 +39,7 @@ module Github
|
|
39
39
|
property :mime_type
|
40
40
|
|
41
41
|
# The value sent in the http header for 'User-Agent' if none is set
|
42
|
-
property :user_agent, default: "Github API Ruby Gem #{Github::VERSION
|
42
|
+
property :user_agent, default: "Github API Ruby Gem #{Github::VERSION}".freeze
|
43
43
|
|
44
44
|
# By default uses the Faraday connection options if none is set
|
45
45
|
property :connection_options, default: {}
|
@@ -3,22 +3,17 @@
|
|
3
3
|
module Github
|
4
4
|
module Validations
|
5
5
|
module Required
|
6
|
-
|
7
6
|
# Validate all keys present in a provided hash against required set,
|
8
7
|
# on mismatch raise Github::Error::RequiredParams
|
9
8
|
# Note that keys need to be in the same format i.e. symbols or strings,
|
10
9
|
# otherwise the comparison will fail.
|
11
10
|
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
raise Github::Error::RequiredParams.new(provided, required)
|
18
|
-
end
|
19
|
-
result
|
11
|
+
# @api public
|
12
|
+
def assert_required_keys(*required, provided)
|
13
|
+
required.flatten.all? { |key|
|
14
|
+
provided.deep_key?(key.to_s)
|
15
|
+
} || (raise Github::Error::RequiredParams.new(provided, required))
|
20
16
|
end
|
21
|
-
|
22
17
|
end # Required
|
23
18
|
end # Validations
|
24
19
|
end # Github
|
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.13.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: 2015-
|
11
|
+
date: 2015-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- lib/github_api/client/markdown.rb
|
180
180
|
- lib/github_api/client/meta.rb
|
181
181
|
- lib/github_api/client/orgs/members.rb
|
182
|
+
- lib/github_api/client/orgs/memberships.rb
|
182
183
|
- lib/github_api/client/orgs/teams.rb
|
183
184
|
- lib/github_api/client/orgs.rb
|
184
185
|
- lib/github_api/client/pull_requests/comments.rb
|
@@ -196,6 +197,7 @@ files:
|
|
196
197
|
- lib/github_api/client/repos/pages.rb
|
197
198
|
- lib/github_api/client/repos/pub_sub_hubbub.rb
|
198
199
|
- lib/github_api/client/repos/releases/assets.rb
|
200
|
+
- lib/github_api/client/repos/releases/tags.rb
|
199
201
|
- lib/github_api/client/repos/releases.rb
|
200
202
|
- lib/github_api/client/repos/statistics.rb
|
201
203
|
- lib/github_api/client/repos/statuses.rb
|