github_api 0.15.0 → 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 +25 -8
- data/lib/github_api.rb +37 -76
- data/lib/github_api/api.rb +46 -19
- data/lib/github_api/api/arguments.rb +6 -1
- data/lib/github_api/api/config.rb +3 -5
- data/lib/github_api/api/config/property_set.rb +1 -0
- data/lib/github_api/authorization.rb +2 -0
- data/lib/github_api/client.rb +5 -0
- data/lib/github_api/client/activity.rb +2 -0
- data/lib/github_api/client/activity/events.rb +2 -0
- data/lib/github_api/client/activity/feeds.rb +2 -0
- data/lib/github_api/client/activity/notifications.rb +2 -0
- data/lib/github_api/client/activity/starring.rb +3 -1
- data/lib/github_api/client/activity/watching.rb +3 -1
- data/lib/github_api/client/authorizations.rb +2 -0
- data/lib/github_api/client/authorizations/app.rb +3 -1
- data/lib/github_api/client/emojis.rb +2 -0
- data/lib/github_api/client/gists.rb +4 -2
- data/lib/github_api/client/gists/comments.rb +3 -1
- data/lib/github_api/client/git_data.rb +2 -0
- data/lib/github_api/client/git_data/blobs.rb +2 -1
- data/lib/github_api/client/git_data/commits.rb +2 -0
- data/lib/github_api/client/git_data/references.rb +6 -2
- data/lib/github_api/client/git_data/tags.rb +2 -0
- data/lib/github_api/client/git_data/trees.rb +2 -0
- data/lib/github_api/client/gitignore.rb +2 -0
- data/lib/github_api/client/issues.rb +2 -0
- data/lib/github_api/client/issues/assignees.rb +35 -0
- data/lib/github_api/client/issues/comments.rb +2 -0
- data/lib/github_api/client/issues/events.rb +2 -0
- data/lib/github_api/client/issues/labels.rb +2 -0
- data/lib/github_api/client/issues/milestones.rb +2 -0
- data/lib/github_api/client/markdown.rb +4 -2
- data/lib/github_api/client/meta.rb +2 -0
- data/lib/github_api/client/orgs.rb +6 -0
- data/lib/github_api/client/orgs/hooks.rb +2 -0
- data/lib/github_api/client/orgs/members.rb +2 -0
- data/lib/github_api/client/orgs/memberships.rb +2 -0
- data/lib/github_api/client/orgs/projects.rb +57 -0
- data/lib/github_api/client/orgs/teams.rb +5 -3
- data/lib/github_api/client/projects.rb +83 -0
- data/lib/github_api/client/projects/cards.rb +158 -0
- data/lib/github_api/client/projects/columns.rb +146 -0
- data/lib/github_api/client/pull_requests.rb +2 -0
- data/lib/github_api/client/pull_requests/comments.rb +2 -0
- data/lib/github_api/client/pull_requests/reviews.rb +2 -0
- data/lib/github_api/client/repos.rb +27 -15
- data/lib/github_api/client/repos/branches.rb +48 -0
- data/lib/github_api/client/repos/branches/protections.rb +75 -0
- data/lib/github_api/client/repos/collaborators.rb +2 -1
- data/lib/github_api/client/repos/comments.rb +2 -1
- data/lib/github_api/client/repos/commits.rb +2 -0
- data/lib/github_api/client/repos/contents.rb +26 -4
- data/lib/github_api/client/repos/deployments.rb +3 -1
- data/lib/github_api/client/repos/downloads.rb +2 -0
- data/lib/github_api/client/repos/forks.rb +6 -2
- data/lib/github_api/client/repos/hooks.rb +2 -0
- data/lib/github_api/client/repos/invitations.rb +41 -0
- data/lib/github_api/client/repos/keys.rb +2 -0
- data/lib/github_api/client/repos/merging.rb +2 -0
- data/lib/github_api/client/repos/pages.rb +2 -0
- data/lib/github_api/client/repos/projects.rb +62 -0
- data/lib/github_api/client/repos/pub_sub_hubbub.rb +6 -6
- data/lib/github_api/client/repos/releases.rb +2 -0
- data/lib/github_api/client/repos/releases/assets.rb +3 -1
- data/lib/github_api/client/repos/releases/tags.rb +2 -0
- data/lib/github_api/client/repos/statistics.rb +2 -0
- data/lib/github_api/client/repos/statuses.rb +2 -0
- data/lib/github_api/client/say.rb +2 -0
- data/lib/github_api/client/scopes.rb +2 -0
- data/lib/github_api/client/search.rb +3 -0
- data/lib/github_api/client/search/legacy.rb +2 -0
- data/lib/github_api/client/users.rb +2 -0
- data/lib/github_api/client/users/emails.rb +3 -0
- data/lib/github_api/client/users/followers.rb +3 -1
- data/lib/github_api/client/users/keys.rb +2 -0
- data/lib/github_api/configuration.rb +4 -1
- data/lib/github_api/connection.rb +5 -1
- data/lib/github_api/error.rb +1 -4
- data/lib/github_api/error/client_error.rb +4 -2
- data/lib/github_api/error/service_error.rb +9 -2
- data/lib/github_api/ext/faraday.rb +3 -1
- data/lib/github_api/mash.rb +7 -0
- data/lib/github_api/middleware.rb +8 -6
- data/lib/github_api/normalizer.rb +3 -5
- data/lib/github_api/page_iterator.rb +4 -1
- data/lib/github_api/page_links.rb +4 -0
- data/lib/github_api/paged_request.rb +2 -0
- data/lib/github_api/pagination.rb +10 -7
- data/lib/github_api/parameter_filter.rb +4 -1
- data/lib/github_api/params_hash.rb +4 -4
- data/lib/github_api/request.rb +8 -9
- data/lib/github_api/request/basic_auth.rb +1 -1
- data/lib/github_api/request/jsonize.rb +0 -1
- data/lib/github_api/request/oauth2.rb +2 -0
- data/lib/github_api/request/verbs.rb +3 -0
- data/lib/github_api/response/follow_redirects.rb +140 -0
- data/lib/github_api/response/header.rb +6 -1
- data/lib/github_api/response/mashify.rb +2 -3
- data/lib/github_api/response/raise_error.rb +2 -1
- data/lib/github_api/response_wrapper.rb +5 -0
- data/lib/github_api/utils/url.rb +2 -0
- data/lib/github_api/validations.rb +5 -8
- data/lib/github_api/validations/format.rb +2 -0
- data/lib/github_api/validations/presence.rb +3 -1
- data/lib/github_api/validations/required.rb +2 -0
- data/lib/github_api/version.rb +2 -2
- metadata +100 -36
- 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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../../../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
# The Release Assets API
|
|
5
7
|
class Client::Repos::Releases::Assets < API
|
|
@@ -35,7 +37,7 @@ module Github
|
|
|
35
37
|
#
|
|
36
38
|
# @api public
|
|
37
39
|
def get(*args)
|
|
38
|
-
|
|
40
|
+
arguments(args, required: [:owner, :repo, :id]).params
|
|
39
41
|
|
|
40
42
|
get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}" , arguments.params)
|
|
41
43
|
end
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
class Client::Users::Followers < API
|
|
5
7
|
|
|
6
8
|
# List a user's followers
|
|
7
9
|
#
|
|
8
|
-
# @
|
|
10
|
+
# @example
|
|
9
11
|
# github = Github.new
|
|
10
12
|
# github.users.followers.list 'user-name'
|
|
11
13
|
# github.users.followers.list 'user-name' { |user| ... }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative 'api/config'
|
|
4
|
+
require_relative 'version'
|
|
4
5
|
|
|
5
6
|
module Github
|
|
6
7
|
# Stores the configuration
|
|
@@ -12,6 +13,8 @@ module Github
|
|
|
12
13
|
# By default, don't traverse the page links
|
|
13
14
|
property :auto_pagination, default: false
|
|
14
15
|
|
|
16
|
+
property :follow_redirects, default: true
|
|
17
|
+
|
|
15
18
|
# Basic authentication
|
|
16
19
|
property :basic_auth
|
|
17
20
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
require_relative 'constants'
|
|
6
|
+
|
|
3
7
|
module Github
|
|
4
8
|
# Specifies Http connection options
|
|
5
9
|
module Connection
|
|
@@ -61,7 +65,7 @@ module Github
|
|
|
61
65
|
|
|
62
66
|
# Creates http connection
|
|
63
67
|
#
|
|
64
|
-
# Returns a
|
|
68
|
+
# Returns a Faraday::Connection object
|
|
65
69
|
def connection(api, options = {})
|
|
66
70
|
connection_options = default_options(options)
|
|
67
71
|
connection_options.merge!(builder: stack(options.merge!(api: api)))
|
data/lib/github_api/error.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Github
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def backtrace
|
|
24
|
-
if @response_message
|
|
24
|
+
if @response_message.respond_to?(:backtrace)
|
|
25
25
|
@response_message.backtrace
|
|
26
26
|
else
|
|
27
27
|
super
|
|
@@ -30,6 +30,3 @@ module Github
|
|
|
30
30
|
end # GithubError
|
|
31
31
|
end # Error
|
|
32
32
|
end # Github
|
|
33
|
-
|
|
34
|
-
require 'github_api/error/service_error'
|
|
35
|
-
require 'github_api/error/client_error'
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../error'
|
|
4
|
+
|
|
3
5
|
module Github #:nodoc
|
|
4
6
|
# Raised when Github returns the HTTP status code 404
|
|
5
7
|
module Error
|
|
@@ -26,7 +28,7 @@ module Github #:nodoc
|
|
|
26
28
|
super(
|
|
27
29
|
generate_message(
|
|
28
30
|
problem: "Invalid option #{invalid.keys.join(', ')} provided for this request.",
|
|
29
|
-
summary: "Github gem checks the request parameters passed to ensure that github api is not hit
|
|
31
|
+
summary: "Github gem checks the request parameters passed to ensure that github api is not hit unnecessarily and to fail fast.",
|
|
30
32
|
resolution: "Valid options are: #{valid.join(', ')}, make sure these are the ones you are using"
|
|
31
33
|
)
|
|
32
34
|
)
|
|
@@ -39,7 +41,7 @@ module Github #:nodoc
|
|
|
39
41
|
super(
|
|
40
42
|
generate_message(
|
|
41
43
|
problem: "Missing required parameters: #{provided.keys.join(', ')} provided for this request.",
|
|
42
|
-
summary: "Github gem checks the request parameters passed to ensure that github api is not hit
|
|
44
|
+
summary: "Github gem checks the request parameters passed to ensure that github api is not hit unnecessarily and to fail fast.",
|
|
43
45
|
resolution: "Required parameters are: #{required.join(', ')}, make sure these are the ones you are using"
|
|
44
46
|
)
|
|
45
47
|
)
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require 'json'
|
|
4
4
|
|
|
5
|
+
require_relative '../error'
|
|
6
|
+
|
|
5
7
|
module Github
|
|
6
8
|
# Raised when GitHub returns any of the HTTP status codes
|
|
7
9
|
module Error
|
|
@@ -31,7 +33,7 @@ module Github
|
|
|
31
33
|
|
|
32
34
|
MIN_BODY_LENGTH = 2
|
|
33
35
|
|
|
34
|
-
#
|
|
36
|
+
# Create a ServiceError
|
|
35
37
|
#
|
|
36
38
|
# @param [Hash[Symbol]] response
|
|
37
39
|
#
|
|
@@ -137,7 +139,12 @@ module Github
|
|
|
137
139
|
elsif data[:errors]
|
|
138
140
|
message = "\nErrors:\n"
|
|
139
141
|
message << data[:errors].map do |error|
|
|
140
|
-
|
|
142
|
+
case error
|
|
143
|
+
when Hash
|
|
144
|
+
"Error: #{error.map { |k, v| "#{k}: #{v}" }.join(', ')}"
|
|
145
|
+
else
|
|
146
|
+
"Error: #{error}"
|
|
147
|
+
end
|
|
141
148
|
end.join("\n")
|
|
142
149
|
end
|
|
143
150
|
end
|
|
@@ -7,7 +7,7 @@ module Faraday
|
|
|
7
7
|
def params_encoder(encoder = nil)
|
|
8
8
|
if encoder
|
|
9
9
|
@encoder = encoder
|
|
10
|
-
|
|
10
|
+
elsif defined?(@encoder)
|
|
11
11
|
@encoder
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -17,6 +17,8 @@ module Faraday
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
module_function
|
|
21
|
+
|
|
20
22
|
def build_nested_query(value, prefix = nil, encoder = nil)
|
|
21
23
|
case value
|
|
22
24
|
when Array
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
require_relative 'response'
|
|
4
|
+
require_relative 'response/mashify'
|
|
5
|
+
require_relative 'response/jsonize'
|
|
6
|
+
require_relative 'response/atom_parser'
|
|
7
|
+
require_relative 'response/raise_error'
|
|
8
|
+
require_relative 'response/header'
|
|
9
|
+
require_relative 'response/follow_redirects'
|
|
9
10
|
|
|
10
11
|
module Github
|
|
11
12
|
class Middleware
|
|
@@ -18,6 +19,7 @@ module Github
|
|
|
18
19
|
builder.use Github::Request::OAuth2, api.oauth_token if api.oauth_token?
|
|
19
20
|
builder.use Github::Request::BasicAuth, api.authentication if api.basic_authed?
|
|
20
21
|
|
|
22
|
+
builder.use Github::Response::FollowRedirects if api.follow_redirects
|
|
21
23
|
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
|
22
24
|
unless options[:raw]
|
|
23
25
|
builder.use Github::Response::Mashify
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# encoding: utf-8
|
|
2
3
|
|
|
3
4
|
module Github
|
|
4
|
-
#
|
|
5
|
+
# Normalize client-supplied parameter keys.
|
|
5
6
|
module Normalizer
|
|
6
7
|
# Turns any keys from nested hashes including nested arrays into strings
|
|
7
|
-
#
|
|
8
8
|
def normalize!(params)
|
|
9
9
|
case params
|
|
10
10
|
when Hash
|
|
@@ -16,10 +16,8 @@ module Github
|
|
|
16
16
|
params.map! do |el|
|
|
17
17
|
normalize!(el)
|
|
18
18
|
end
|
|
19
|
-
else
|
|
20
|
-
params.to_s
|
|
21
19
|
end
|
|
22
|
-
|
|
20
|
+
params
|
|
23
21
|
end
|
|
24
22
|
end # Normalizer
|
|
25
23
|
end # Github
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
require 'github_api/utils/url'
|
|
4
3
|
require 'uri'
|
|
5
4
|
|
|
5
|
+
require_relative 'constants'
|
|
6
|
+
require_relative 'paged_request'
|
|
7
|
+
require_relative 'utils/url'
|
|
8
|
+
|
|
6
9
|
module Github
|
|
7
10
|
# A class responsible for requesting resources through page links
|
|
8
11
|
#
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative 'constants'
|
|
4
|
+
require_relative 'page_links'
|
|
5
|
+
require_relative 'page_iterator'
|
|
4
6
|
|
|
7
|
+
module Github
|
|
5
8
|
# A module that decorates response with pagination helpers
|
|
6
9
|
module Pagination
|
|
7
10
|
include Github::Constants
|
|
@@ -11,7 +14,7 @@ module Github
|
|
|
11
14
|
@links = Github::PageLinks.new(env[:response_headers])
|
|
12
15
|
end
|
|
13
16
|
|
|
14
|
-
#
|
|
17
|
+
# Retrieve number of total pages base on current :per_page parameter
|
|
15
18
|
def count_pages
|
|
16
19
|
page_iterator.count.to_i
|
|
17
20
|
end
|
|
@@ -40,7 +43,7 @@ module Github
|
|
|
40
43
|
end
|
|
41
44
|
end
|
|
42
45
|
|
|
43
|
-
#
|
|
46
|
+
# Retrieves the result of the first page. Returns <tt>nil</tt> if there is
|
|
44
47
|
# no first page - either because you are already on the first page
|
|
45
48
|
# or there are no pages at all in the result.
|
|
46
49
|
def first_page
|
|
@@ -49,7 +52,7 @@ module Github
|
|
|
49
52
|
first_request
|
|
50
53
|
end
|
|
51
54
|
|
|
52
|
-
#
|
|
55
|
+
# Retrieves the result of the next page. Returns <tt>nil</tt> if there is
|
|
53
56
|
# no next page or no pages at all.
|
|
54
57
|
def next_page
|
|
55
58
|
next_request = page_iterator.next
|
|
@@ -57,7 +60,7 @@ module Github
|
|
|
57
60
|
next_request
|
|
58
61
|
end
|
|
59
62
|
|
|
60
|
-
#
|
|
63
|
+
# Retrieves the result of the previous page. Returns <tt>nil</tt> if there is
|
|
61
64
|
# no previous page or no pages at all.
|
|
62
65
|
def prev_page
|
|
63
66
|
prev_request = page_iterator.prev
|
|
@@ -66,7 +69,7 @@ module Github
|
|
|
66
69
|
end
|
|
67
70
|
alias :previous_page :prev_page
|
|
68
71
|
|
|
69
|
-
#
|
|
72
|
+
# Retrieves the result of the last page. Returns <tt>nil</tt> if there is
|
|
70
73
|
# no last page - either because you are already on the last page,
|
|
71
74
|
# there is only one page or there are no pages at all in the result.
|
|
72
75
|
def last_page
|
|
@@ -75,7 +78,7 @@ module Github
|
|
|
75
78
|
last_request
|
|
76
79
|
end
|
|
77
80
|
|
|
78
|
-
#
|
|
81
|
+
# Retrieves a specific result for a page given page number.
|
|
79
82
|
# The <tt>page_number</tt> parameter is not validate, hitting a page
|
|
80
83
|
# that does not exist will return Github API error. Consequently, if
|
|
81
84
|
# there is only one page, this method returns nil
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
require 'delegate'
|
|
4
4
|
require 'base64'
|
|
5
5
|
|
|
6
|
+
require_relative 'normalizer'
|
|
7
|
+
require_relative 'mime_type'
|
|
8
|
+
|
|
6
9
|
module Github
|
|
7
10
|
# Class responsible for holding request parameters
|
|
8
11
|
class ParamsHash < DelegateClass(Hash)
|
|
9
12
|
include Normalizer
|
|
10
13
|
include MimeType
|
|
11
14
|
|
|
12
|
-
REQUEST_PARAMS = [:accept, :media, :data, :raw, :
|
|
15
|
+
REQUEST_PARAMS = [:accept, :media, :data, :raw, :headers]
|
|
13
16
|
|
|
14
17
|
def initialize(hash)
|
|
15
18
|
super(normalize!(Hash[hash]))
|
|
@@ -71,9 +74,6 @@ module Github
|
|
|
71
74
|
if value = accept
|
|
72
75
|
headers[:accept] = value
|
|
73
76
|
end
|
|
74
|
-
if self['content_type']
|
|
75
|
-
headers[:content_type] = self['content_type']
|
|
76
|
-
end
|
|
77
77
|
opts[:raw] = key?('raw') ? self['raw'] : false
|
|
78
78
|
opts[:headers] = headers unless headers.empty?
|
|
79
79
|
opts
|