github_api 0.18.2 → 0.19.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 +5 -5
- data/CHANGELOG.md +770 -0
- data/README.md +3 -5
- data/lib/github_api.rb +0 -1
- data/lib/github_api/api.rb +1 -1
- data/lib/github_api/api/arguments.rb +1 -1
- data/lib/github_api/api/config.rb +1 -1
- data/lib/github_api/client/activity/starring.rb +1 -1
- data/lib/github_api/client/activity/watching.rb +1 -1
- data/lib/github_api/client/gists.rb +2 -2
- data/lib/github_api/client/gists/comments.rb +1 -1
- data/lib/github_api/client/git_data/references.rb +4 -2
- data/lib/github_api/client/markdown.rb +1 -1
- data/lib/github_api/client/orgs/teams.rb +3 -3
- data/lib/github_api/client/projects/cards.rb +2 -2
- data/lib/github_api/client/repos.rb +6 -1
- data/lib/github_api/client/repos/branches/protections.rb +1 -1
- data/lib/github_api/client/repos/contents.rb +20 -3
- data/lib/github_api/client/repos/deployments.rb +1 -1
- data/lib/github_api/client/repos/forks.rb +4 -2
- data/lib/github_api/client/repos/invitations.rb +41 -0
- data/lib/github_api/connection.rb +1 -1
- data/lib/github_api/error/service_error.rb +1 -1
- data/lib/github_api/ext/faraday.rb +2 -0
- data/lib/github_api/pagination.rb +6 -6
- data/lib/github_api/request.rb +2 -3
- data/lib/github_api/response/follow_redirects.rb +1 -1
- data/lib/github_api/validations/presence.rb +1 -1
- data/lib/github_api/version.rb +2 -2
- metadata +40 -26
- data/lib/github_api/core_ext/ordered_hash.rb +0 -107
- data/lib/github_api/requestable.rb +0 -67
- data/lib/github_api/resource.rb +0 -13
data/README.md
CHANGED
@@ -6,18 +6,16 @@
|
|
6
6
|
|
7
7
|
[][gem]
|
8
8
|
[][travis]
|
9
|
-
[][codeclimate]
|
10
10
|
[][coverage]
|
11
11
|
[][inchpages]
|
12
|
-
[][gemnasium]
|
13
12
|
|
14
13
|
[gitter]: https://gitter.im/piotrmurach/github_api
|
15
14
|
[gem]: http://badge.fury.io/rb/github_api
|
16
15
|
[travis]: http://travis-ci.org/piotrmurach/github
|
17
|
-
[codeclimate]: https://codeclimate.com/github/piotrmurach/github
|
16
|
+
[codeclimate]: https://codeclimate.com/github/piotrmurach/github/maintainability
|
18
17
|
[coverage]: https://coveralls.io/r/piotrmurach/github
|
19
18
|
[inchpages]: http://inch-ci.org/github/piotrmurach/github
|
20
|
-
[gemnasium]: https://gemnasium.com/piotrmurach/github
|
21
19
|
|
22
20
|
[Website](http://piotrmurach.github.io/github/) | [Wiki](https://github.com/piotrmurach/github/wiki) | [RDocs](http://rubydoc.info/github/piotrmurach/github/master/frames)
|
23
21
|
|
@@ -738,4 +736,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrm
|
|
738
736
|
|
739
737
|
## Copyright
|
740
738
|
|
741
|
-
Copyright (c) 2011
|
739
|
+
Copyright (c) 2011 Piotr Murach. See LICENSE.txt for further details.
|
data/lib/github_api.rb
CHANGED
@@ -88,6 +88,5 @@ require_relative 'github_api/configuration'
|
|
88
88
|
require_relative 'github_api/deprecation'
|
89
89
|
require_relative 'github_api/core_ext/array'
|
90
90
|
require_relative 'github_api/core_ext/hash'
|
91
|
-
require_relative 'github_api/core_ext/ordered_hash'
|
92
91
|
require_relative 'github_api/middleware'
|
93
92
|
require_relative 'github_api/version'
|
data/lib/github_api/api.rb
CHANGED
@@ -118,7 +118,7 @@ module Github
|
|
118
118
|
# github.activity.starring.unstar 'user-name', 'repo-name'
|
119
119
|
#
|
120
120
|
# @example
|
121
|
-
# github.
|
121
|
+
# github.activity.starring.unstar user: 'user-name', repo: 'repo-name'
|
122
122
|
#
|
123
123
|
# @api public
|
124
124
|
def unstar(*args)
|
@@ -13,7 +13,7 @@ module Github
|
|
13
13
|
# @example
|
14
14
|
# github = Github.new
|
15
15
|
# github.activity.watching.list user: 'user-name', repo: 'repo-name'
|
16
|
-
# github.activity.watching.list user: 'user-
|
16
|
+
# github.activity.watching.list user: 'user-name', repo: 'repo-name' { |watcher| ... }
|
17
17
|
#
|
18
18
|
# @api public
|
19
19
|
def list(*args)
|
@@ -143,7 +143,7 @@ module Github
|
|
143
143
|
# Optional string
|
144
144
|
# @option [Hash] :files
|
145
145
|
# Optional hash - Files that make up this gist.
|
146
|
-
# The key of which should be a optional string filename and
|
146
|
+
# The key of which should be a optional string filename and
|
147
147
|
# the value another optional hash with parameters:
|
148
148
|
# @option [String] :content
|
149
149
|
# Updated string - Update file contents.
|
@@ -213,7 +213,7 @@ module Github
|
|
213
213
|
#
|
214
214
|
# @see https://developer.github.com/v3/gists/#unstar-a-gist
|
215
215
|
#
|
216
|
-
# @
|
216
|
+
# @example
|
217
217
|
# github = Github.new
|
218
218
|
# github.gists.unstar 'gist-id'
|
219
219
|
#
|
@@ -35,8 +35,8 @@ module Github
|
|
35
35
|
repo = arguments.repo
|
36
36
|
|
37
37
|
response = if (ref = params.delete('ref'))
|
38
|
-
validate_reference ref
|
39
|
-
get_request("/repos/#{user}/#{repo}/git
|
38
|
+
formatted_ref = validate_reference ref
|
39
|
+
get_request("/repos/#{user}/#{repo}/git/#{formatted_ref}", params)
|
40
40
|
else
|
41
41
|
get_request("/repos/#{user}/#{repo}/git/refs", params)
|
42
42
|
end
|
@@ -143,6 +143,8 @@ module Github
|
|
143
143
|
unless VALID_REF_PARAM_VALUES['ref'] =~ refs
|
144
144
|
raise ArgumentError, "Provided 'reference' is invalid"
|
145
145
|
end
|
146
|
+
|
147
|
+
refs
|
146
148
|
end
|
147
149
|
end # GitData::References
|
148
150
|
end # Github
|
@@ -79,7 +79,7 @@ module Github
|
|
79
79
|
# * pull - team members can pull, but not push or
|
80
80
|
# administor this repositories.
|
81
81
|
# * push - team members can pull and push,
|
82
|
-
# but not
|
82
|
+
# but not administer this repositores.
|
83
83
|
# * admin - team members can pull, push and
|
84
84
|
# administor these repositories.
|
85
85
|
# Default: pull
|
@@ -125,9 +125,9 @@ module Github
|
|
125
125
|
# * pull - team members can pull, but not push or
|
126
126
|
# administor this repositories.
|
127
127
|
# * push - team members can pull and push,
|
128
|
-
# but not
|
128
|
+
# but not administer this repositores.
|
129
129
|
# * admin - team members can pull, push and
|
130
|
-
#
|
130
|
+
# administer these repositories.
|
131
131
|
# Default: pull
|
132
132
|
#
|
133
133
|
# @example
|
@@ -66,8 +66,8 @@ module Github
|
|
66
66
|
# github.projects.cards.create :column_id, note: 'Card Note'
|
67
67
|
#
|
68
68
|
# @example
|
69
|
-
#
|
70
|
-
#
|
69
|
+
# github = Github.new
|
70
|
+
# github.projects.cards.create :column_id, content_id: <content-id>, content_type: 'content-type'
|
71
71
|
#
|
72
72
|
# @see https://developer.github.com/v3/projects/cards/#create-a-project-card
|
73
73
|
#
|
@@ -15,6 +15,7 @@ module Github
|
|
15
15
|
'downloads',
|
16
16
|
'forks',
|
17
17
|
'hooks',
|
18
|
+
'invitations',
|
18
19
|
'keys',
|
19
20
|
'merging',
|
20
21
|
'pages',
|
@@ -32,6 +33,7 @@ module Github
|
|
32
33
|
homepage
|
33
34
|
private
|
34
35
|
has_issues
|
36
|
+
has_projects
|
35
37
|
has_wiki
|
36
38
|
has_downloads
|
37
39
|
team_id
|
@@ -66,6 +68,9 @@ module Github
|
|
66
68
|
# Access to Repos::Hooks API
|
67
69
|
namespace :hooks
|
68
70
|
|
71
|
+
# Access to Repos::Invitations API
|
72
|
+
namespace :invitations
|
73
|
+
|
69
74
|
# Access to Repos::Keys API
|
70
75
|
namespace :keys
|
71
76
|
|
@@ -183,7 +188,7 @@ module Github
|
|
183
188
|
end
|
184
189
|
alias :find_by_id :get_by_id
|
185
190
|
|
186
|
-
# Create a new repository for the
|
191
|
+
# Create a new repository for the authenticated user.
|
187
192
|
#
|
188
193
|
# @param [Hash] params
|
189
194
|
# @option params [String] :name
|
@@ -40,7 +40,7 @@ module Github
|
|
40
40
|
# Required.
|
41
41
|
# @input params [String] :required_pull_request_reviews
|
42
42
|
# Required.
|
43
|
-
# Look to the branch protection API
|
43
|
+
# Look to the branch protection API to see how to use these
|
44
44
|
# https://developer.github.com/v3/repos/branches/#update-branch-protection
|
45
45
|
#
|
46
46
|
# @example
|
@@ -33,6 +33,23 @@ module Github
|
|
33
33
|
get_request("/repos/#{arguments.user}/#{arguments.repo}/readme", arguments.params)
|
34
34
|
end
|
35
35
|
|
36
|
+
# Get the LICENSE
|
37
|
+
#
|
38
|
+
# This method returns the contents of the repository's license file, if one is detected.
|
39
|
+
#
|
40
|
+
# @param [Hash] params
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# github = Github.new
|
44
|
+
# github.repos.contents.license 'user-name', 'repo-name'
|
45
|
+
#
|
46
|
+
# @api public
|
47
|
+
def license(*args)
|
48
|
+
arguments(args, required: [:user, :repo])
|
49
|
+
|
50
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/license", arguments.params)
|
51
|
+
end
|
52
|
+
|
36
53
|
# Get contents
|
37
54
|
#
|
38
55
|
# This method returns the contents of any file or directory in a repository.
|
@@ -66,12 +83,12 @@ module Github
|
|
66
83
|
#
|
67
84
|
# @param [Hash] params
|
68
85
|
# @option params [String] :path
|
69
|
-
#
|
86
|
+
# Required string. The content path
|
70
87
|
# @option params [String]
|
71
88
|
# @option params [String] :message
|
72
|
-
#
|
89
|
+
# Required string. The commit message.
|
73
90
|
# @option params [String] :content
|
74
|
-
#
|
91
|
+
# Required string. The new file content, which will be Base64 encoded
|
75
92
|
# @option params [String] :branch
|
76
93
|
# The branch name. If not provided, uses the repository’s
|
77
94
|
# default branch (usually master)
|
@@ -13,8 +13,10 @@ module Github
|
|
13
13
|
#
|
14
14
|
# @example
|
15
15
|
# github = Github.new
|
16
|
-
# github.repos.forks.list
|
17
|
-
# github.repos.forks.list
|
16
|
+
# github.repos.forks.list('user-name', 'repo-name')
|
17
|
+
# github.repos.forks.list('user-name', 'repo-name') { |fork|
|
18
|
+
# #...
|
19
|
+
# }
|
18
20
|
#
|
19
21
|
# @api public
|
20
22
|
def list(*args)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
class Client::Repos::Invitations < API
|
7
|
+
# List repo invitations
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# github = Github.new
|
11
|
+
# github.repos.invitations.list 'user-name', 'repo-name'
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# github.repos.invitations.list 'user-name', 'repo-name' { |cbr| .. }
|
15
|
+
#
|
16
|
+
# @return [Array]
|
17
|
+
#
|
18
|
+
# @api public
|
19
|
+
def list(*args)
|
20
|
+
arguments(args, required: [:user, :repo])
|
21
|
+
|
22
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/invitations", arguments.params)
|
23
|
+
return response unless block_given?
|
24
|
+
response.each { |el| yield el }
|
25
|
+
end
|
26
|
+
alias :all :list
|
27
|
+
|
28
|
+
# Deletes a repo invitation
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# github = Github.new
|
32
|
+
# github.repos.invitations.delete 'user-name', 'repo-name', 'invitation-id'
|
33
|
+
#
|
34
|
+
# @api public
|
35
|
+
def delete(*args)
|
36
|
+
arguments(args, required: [:user, :repo, :id])
|
37
|
+
|
38
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/invitations/#{arguments.id}", arguments.params)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -65,7 +65,7 @@ module Github
|
|
65
65
|
|
66
66
|
# Creates http connection
|
67
67
|
#
|
68
|
-
# Returns a
|
68
|
+
# Returns a Faraday::Connection object
|
69
69
|
def connection(api, options = {})
|
70
70
|
connection_options = default_options(options)
|
71
71
|
connection_options.merge!(builder: stack(options.merge!(api: api)))
|
@@ -14,7 +14,7 @@ module Github
|
|
14
14
|
@links = Github::PageLinks.new(env[:response_headers])
|
15
15
|
end
|
16
16
|
|
17
|
-
#
|
17
|
+
# Retrieve number of total pages base on current :per_page parameter
|
18
18
|
def count_pages
|
19
19
|
page_iterator.count.to_i
|
20
20
|
end
|
@@ -43,7 +43,7 @@ module Github
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
#
|
46
|
+
# Retrieves the result of the first page. Returns <tt>nil</tt> if there is
|
47
47
|
# no first page - either because you are already on the first page
|
48
48
|
# or there are no pages at all in the result.
|
49
49
|
def first_page
|
@@ -52,7 +52,7 @@ module Github
|
|
52
52
|
first_request
|
53
53
|
end
|
54
54
|
|
55
|
-
#
|
55
|
+
# Retrieves the result of the next page. Returns <tt>nil</tt> if there is
|
56
56
|
# no next page or no pages at all.
|
57
57
|
def next_page
|
58
58
|
next_request = page_iterator.next
|
@@ -60,7 +60,7 @@ module Github
|
|
60
60
|
next_request
|
61
61
|
end
|
62
62
|
|
63
|
-
#
|
63
|
+
# Retrieves the result of the previous page. Returns <tt>nil</tt> if there is
|
64
64
|
# no previous page or no pages at all.
|
65
65
|
def prev_page
|
66
66
|
prev_request = page_iterator.prev
|
@@ -69,7 +69,7 @@ module Github
|
|
69
69
|
end
|
70
70
|
alias :previous_page :prev_page
|
71
71
|
|
72
|
-
#
|
72
|
+
# Retrieves the result of the last page. Returns <tt>nil</tt> if there is
|
73
73
|
# no last page - either because you are already on the last page,
|
74
74
|
# there is only one page or there are no pages at all in the result.
|
75
75
|
def last_page
|
@@ -78,7 +78,7 @@ module Github
|
|
78
78
|
last_request
|
79
79
|
end
|
80
80
|
|
81
|
-
#
|
81
|
+
# Retrieves a specific result for a page given page number.
|
82
82
|
# The <tt>page_number</tt> parameter is not validate, hitting a page
|
83
83
|
# that does not exist will return Github API error. Consequently, if
|
84
84
|
# there is only one page, this method returns nil
|
data/lib/github_api/request.rb
CHANGED
@@ -43,8 +43,7 @@ module Github
|
|
43
43
|
|
44
44
|
# Performs a request
|
45
45
|
#
|
46
|
-
# @param [
|
47
|
-
# @param [String] path - String relative URL to access
|
46
|
+
# @param current_options [Hash]
|
48
47
|
# @param [ParamsHash] params - ParamsHash to configure the request API
|
49
48
|
#
|
50
49
|
# @return [Github::ResponseWrapper]
|
@@ -52,7 +51,7 @@ module Github
|
|
52
51
|
# @api private
|
53
52
|
def call(current_options, params)
|
54
53
|
unless HTTP_METHODS.include?(action)
|
55
|
-
raise ArgumentError, "unknown http method: #{
|
54
|
+
raise ArgumentError, "unknown http method: #{action}"
|
56
55
|
end
|
57
56
|
|
58
57
|
puts "EXECUTED: #{action} - #{path} with PARAMS: #{params.request_params}" if ENV['DEBUG']
|
@@ -8,7 +8,7 @@ require 'set'
|
|
8
8
|
|
9
9
|
module Github
|
10
10
|
# Public: Exception thrown when the maximum amount of requests is exceeded.
|
11
|
-
class RedirectLimitReached < Faraday::
|
11
|
+
class RedirectLimitReached < Faraday::ClientError
|
12
12
|
attr_reader :response
|
13
13
|
|
14
14
|
def initialize(response)
|
@@ -7,7 +7,7 @@ module Github
|
|
7
7
|
# A mixin to help validate presence of non-empty values
|
8
8
|
module Presence
|
9
9
|
|
10
|
-
# Ensure that
|
10
|
+
# Ensure that essential arguments are present before request is made.
|
11
11
|
#
|
12
12
|
# == Parameters
|
13
13
|
# Hash/Array of arguments to be checked against nil and empty string
|