github_api 0.17.0 → 0.18.1

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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/lib/github_api.rb +38 -76
  3. data/lib/github_api/api.rb +35 -18
  4. data/lib/github_api/api/arguments.rb +5 -0
  5. data/lib/github_api/api/config.rb +2 -4
  6. data/lib/github_api/api/config/property_set.rb +1 -0
  7. data/lib/github_api/authorization.rb +2 -0
  8. data/lib/github_api/client.rb +2 -0
  9. data/lib/github_api/client/activity.rb +2 -0
  10. data/lib/github_api/client/activity/events.rb +2 -0
  11. data/lib/github_api/client/activity/feeds.rb +2 -0
  12. data/lib/github_api/client/activity/notifications.rb +2 -0
  13. data/lib/github_api/client/activity/starring.rb +2 -0
  14. data/lib/github_api/client/activity/watching.rb +2 -0
  15. data/lib/github_api/client/authorizations.rb +2 -0
  16. data/lib/github_api/client/authorizations/app.rb +3 -1
  17. data/lib/github_api/client/emojis.rb +2 -0
  18. data/lib/github_api/client/gists.rb +2 -0
  19. data/lib/github_api/client/gists/comments.rb +2 -0
  20. data/lib/github_api/client/git_data.rb +2 -0
  21. data/lib/github_api/client/git_data/blobs.rb +2 -1
  22. data/lib/github_api/client/git_data/commits.rb +2 -0
  23. data/lib/github_api/client/git_data/references.rb +2 -0
  24. data/lib/github_api/client/git_data/tags.rb +2 -0
  25. data/lib/github_api/client/git_data/trees.rb +2 -0
  26. data/lib/github_api/client/gitignore.rb +2 -0
  27. data/lib/github_api/client/issues.rb +2 -0
  28. data/lib/github_api/client/issues/assignees.rb +35 -0
  29. data/lib/github_api/client/issues/comments.rb +2 -0
  30. data/lib/github_api/client/issues/events.rb +2 -0
  31. data/lib/github_api/client/issues/labels.rb +2 -0
  32. data/lib/github_api/client/issues/milestones.rb +2 -0
  33. data/lib/github_api/client/markdown.rb +3 -1
  34. data/lib/github_api/client/meta.rb +2 -0
  35. data/lib/github_api/client/orgs.rb +2 -0
  36. data/lib/github_api/client/orgs/hooks.rb +2 -0
  37. data/lib/github_api/client/orgs/members.rb +2 -0
  38. data/lib/github_api/client/orgs/memberships.rb +2 -0
  39. data/lib/github_api/client/orgs/projects.rb +2 -0
  40. data/lib/github_api/client/orgs/teams.rb +2 -0
  41. data/lib/github_api/client/projects.rb +2 -0
  42. data/lib/github_api/client/projects/cards.rb +3 -1
  43. data/lib/github_api/client/projects/columns.rb +2 -0
  44. data/lib/github_api/client/pull_requests.rb +2 -0
  45. data/lib/github_api/client/pull_requests/comments.rb +2 -0
  46. data/lib/github_api/client/pull_requests/reviews.rb +2 -0
  47. data/lib/github_api/client/repos.rb +17 -13
  48. data/lib/github_api/client/repos/branches.rb +48 -0
  49. data/lib/github_api/client/repos/branches/protections.rb +75 -0
  50. data/lib/github_api/client/repos/collaborators.rb +2 -1
  51. data/lib/github_api/client/repos/comments.rb +2 -0
  52. data/lib/github_api/client/repos/commits.rb +2 -0
  53. data/lib/github_api/client/repos/contents.rb +2 -0
  54. data/lib/github_api/client/repos/deployments.rb +2 -0
  55. data/lib/github_api/client/repos/downloads.rb +2 -0
  56. data/lib/github_api/client/repos/forks.rb +2 -0
  57. data/lib/github_api/client/repos/hooks.rb +2 -0
  58. data/lib/github_api/client/repos/keys.rb +2 -0
  59. data/lib/github_api/client/repos/merging.rb +2 -0
  60. data/lib/github_api/client/repos/pages.rb +2 -0
  61. data/lib/github_api/client/repos/projects.rb +4 -2
  62. data/lib/github_api/client/repos/pub_sub_hubbub.rb +2 -0
  63. data/lib/github_api/client/repos/releases.rb +2 -0
  64. data/lib/github_api/client/repos/releases/assets.rb +3 -1
  65. data/lib/github_api/client/repos/releases/tags.rb +2 -0
  66. data/lib/github_api/client/repos/statistics.rb +2 -0
  67. data/lib/github_api/client/repos/statuses.rb +2 -0
  68. data/lib/github_api/client/say.rb +2 -0
  69. data/lib/github_api/client/scopes.rb +2 -0
  70. data/lib/github_api/client/search.rb +3 -0
  71. data/lib/github_api/client/search/legacy.rb +2 -0
  72. data/lib/github_api/client/users.rb +2 -0
  73. data/lib/github_api/client/users/emails.rb +3 -0
  74. data/lib/github_api/client/users/followers.rb +2 -0
  75. data/lib/github_api/client/users/keys.rb +2 -0
  76. data/lib/github_api/configuration.rb +2 -1
  77. data/lib/github_api/connection.rb +4 -0
  78. data/lib/github_api/error.rb +1 -4
  79. data/lib/github_api/error/client_error.rb +2 -0
  80. data/lib/github_api/error/service_error.rb +2 -0
  81. data/lib/github_api/ext/faraday.rb +1 -1
  82. data/lib/github_api/middleware.rb +7 -7
  83. data/lib/github_api/page_iterator.rb +4 -1
  84. data/lib/github_api/page_links.rb +4 -0
  85. data/lib/github_api/paged_request.rb +2 -0
  86. data/lib/github_api/pagination.rb +4 -1
  87. data/lib/github_api/parameter_filter.rb +4 -1
  88. data/lib/github_api/params_hash.rb +3 -0
  89. data/lib/github_api/request.rb +5 -5
  90. data/lib/github_api/request/jsonize.rb +0 -1
  91. data/lib/github_api/request/oauth2.rb +2 -0
  92. data/lib/github_api/request/verbs.rb +3 -0
  93. data/lib/github_api/response/header.rb +2 -0
  94. data/lib/github_api/response/raise_error.rb +2 -1
  95. data/lib/github_api/response_wrapper.rb +5 -0
  96. data/lib/github_api/utils/url.rb +2 -0
  97. data/lib/github_api/validations.rb +5 -8
  98. data/lib/github_api/validations/format.rb +2 -0
  99. data/lib/github_api/validations/presence.rb +2 -0
  100. data/lib/github_api/validations/required.rb +2 -0
  101. data/lib/github_api/version.rb +1 -1
  102. metadata +9 -34
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::Comments < API
5
7
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::Commits < API
5
7
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # These API methods let you retrieve the contents of files within a repository
5
7
  # as Base64 encoded content.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::Deployments < API
5
7
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::Downloads < API
5
7
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::Forks < API
5
7
  # List repository forks
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # The Repository Hooks API manages the post-receive web and
5
7
  # service hooks for a repository.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::Keys < API
5
7
  # List deploy keys
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # The Repo Merging API supports merging branches in a repository. This
5
7
  # accomplishes essentially the same thing as merging one branch into another
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # The Pages API retrieves information about your GitHub Pages configuration,
5
7
  # and the statuses of your builds. Information about the site and the builds
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::Projects < API
5
7
  PREVIEW_MEDIA = "application/vnd.github.inertia-preview+json".freeze # :nodoc:
@@ -42,8 +44,8 @@ module Github
42
44
  #
43
45
  # @example
44
46
  # github = Github.new
45
- # github.repos.create 'owner-name', 'repo-name', name: 'project-name'
46
- # github.repos.create name: 'project-name', body: 'project-body', owner: 'owner-name', repo: 'repo-name'
47
+ # github.repos.projects.create 'owner-name', 'repo-name', name: 'project-name'
48
+ # github.repos.projects.create name: 'project-name', body: 'project-body', owner: 'owner-name', repo: 'repo-name'
47
49
  #
48
50
  # @api public
49
51
  def create(*args)
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Repos::PubSubHubbub < API
5
7
  HEADERS = {
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # The Releases API
5
7
  class Client::Repos::Releases < API
@@ -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
- params = arguments(args, required: [:owner, :repo, :id]).params
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,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../../api'
4
+
3
5
  module Github
4
6
  # The Releases API
5
7
  class Client::Repos::Releases::Tags < API
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # The Repository Statistics API allows you to fetch the data that GitHub uses
5
7
  # for visualizing different types of repository activity.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # The Status API allows external services to mark commits with a success,
5
7
  # failure, error, or pending state, which is then reflected in pull requests
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::Say < API
5
7
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::Scopes < API
5
7
  # Check what OAuth scopes you have.
@@ -1,5 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+ require_relative '../utils/url'
5
+
3
6
  module Github
4
7
  # The Search API is optimized to help you find the specific item
5
8
  # you're looking for (e.g., a specific user, a specific file
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Search::Legacy < API
5
7
  include Github::Utils::Url
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::Users < API
5
7
  # Load all the modules after initializing Repos to avoid superclass mismatch
@@ -1,6 +1,9 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'cgi'
3
4
 
5
+ require_relative '../../api'
6
+
4
7
  module Github
5
8
  class Client::Users::Emails < API
6
9
 
@@ -1,5 +1,7 @@
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
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Users::Keys < API
5
7
 
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'github_api/api/config'
3
+ require_relative 'api/config'
4
+ require_relative 'version'
4
5
 
5
6
  module Github
6
7
  # Stores the configuration
@@ -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
@@ -21,7 +21,7 @@ module Github
21
21
  end
22
22
 
23
23
  def backtrace
24
- if @response_message && @response_message.respond_to?(:backtrace)
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
@@ -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
@@ -7,7 +7,7 @@ module Faraday
7
7
  def params_encoder(encoder = nil)
8
8
  if encoder
9
9
  @encoder = encoder
10
- else
10
+ elsif defined?(@encoder)
11
11
  @encoder
12
12
  end
13
13
  end
@@ -1,12 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'github_api/response'
4
- require 'github_api/response/mashify'
5
- require 'github_api/response/jsonize'
6
- require 'github_api/response/atom_parser'
7
- require 'github_api/response/raise_error'
8
- require 'github_api/response/header'
9
- require 'github_api/response/follow_redirects'
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'
10
10
 
11
11
  module Github
12
12
  class Middleware
@@ -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,3 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'constants'
4
+
1
5
  module Github
2
6
  # Determines the links in the current response link header to be used
3
7
  # to find the links to other pages of request responses. These will
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative 'constants'
4
+
3
5
  module Github
4
6
 
5
7
  # A module that adds http get request to response pagination
@@ -1,7 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Github
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
@@ -1,4 +1,7 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
+
3
+ require_relative 'params_hash'
4
+ require_relative 'validations'
2
5
 
3
6
  module Github
4
7
  # Allows you to specify parameters keys which will be preserved
@@ -3,6 +3,9 @@
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)
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'github_api/request/oauth2'
4
- require 'github_api/request/basic_auth'
5
- require 'github_api/request/jsonize'
6
-
7
- require 'github_api/connection'
3
+ require_relative 'connection'
4
+ require_relative 'response_wrapper'
5
+ require_relative 'request/oauth2'
6
+ require_relative 'request/basic_auth'
7
+ require_relative 'request/jsonize'
8
8
 
9
9
  module Github
10
10
  # A class responsible for dispatching http requests
@@ -32,7 +32,6 @@ module Github
32
32
  end
33
33
 
34
34
  def request_with_body?(env)
35
- type = request_type(env)
36
35
  has_body?(env) and safe_to_modify?(env)
37
36
  end
38
37
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'faraday'
4
4
 
5
+ require_relative '../utils/url'
6
+
5
7
  module Github
6
8
  class Request
7
9
  class OAuth2 < Faraday::Middleware
@@ -1,5 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../request'
4
+ require_relative '../params_hash'
5
+
3
6
  module Github
4
7
  # A class responsible for dispatching http requests
5
8
  class Request
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../constants'
4
+
3
5
  module Github
4
6
  class Response
5
7