github_api 0.17.0 → 0.18.1

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78e5b988d1308a8fb225d36cab72b3fdb9643fe3
4
- data.tar.gz: a66c54c119e6e9bf4c12dda1de545a5a1cdba5a7
3
+ metadata.gz: 11a8e6228c2919e3c6de1b8242da1ef610216b34
4
+ data.tar.gz: 0b7aa20dd2b819fb821a5610becad83c2a965dfa
5
5
  SHA512:
6
- metadata.gz: 972cd5cb9b8c5eac8a3697a00a2bc578abc0758694bd9028631f7bbd81a416b4be9816ac2c9f168a5b414f6b9b05424725ef87184a47e8ab26895ba71088e31d
7
- data.tar.gz: e1987a1183df4060db459a10771eb2a00bc669499edb315fcc862e98ffb4414eba385a53cf04b8299a0b6e3f3a313d002c261109b2f917606b7e2243855c84ba
6
+ metadata.gz: c95237edd052e4baa7992814412a54e42160c9b72537b5205847ea957cb96abac0177f4c897e8968b4cb32393422ab39732d18277bc00d41f9af46ce4d2b7625
7
+ data.tar.gz: b8833f282be713c2c271035b4a6090aeee1e346062f944dab6611084a0db05831f7ab7d0e4351ef9ee03e7fb6d2352c3bb2b550f99ce87e59b2c37e463b62009
@@ -1,16 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'pp' if ENV['DEBUG']
4
+
4
5
  require 'faraday'
5
- require 'github_api/version'
6
- require 'github_api/configuration'
7
- require 'github_api/constants'
8
- require 'github_api/utils/url'
9
- require 'github_api/connection'
10
- require 'github_api/deprecation'
11
- require 'github_api/core_ext/ordered_hash'
12
- require 'github_api/ext/faraday'
13
- require 'github_api/middleware'
6
+ require_relative 'github_api/ext/faraday'
14
7
 
15
8
  module Github
16
9
  LIBNAME = 'github_api'
@@ -18,8 +11,32 @@ module Github
18
11
  LIBDIR = File.expand_path("../#{LIBNAME}", __FILE__)
19
12
 
20
13
  class << self
21
- def included(base)
22
- base.extend ClassMethods
14
+ # The client configuration
15
+ #
16
+ # @return [Configuration]
17
+ #
18
+ # @api public
19
+ def configuration
20
+ @configuration ||= Configuration.new
21
+ end
22
+ alias_method :config, :configuration
23
+
24
+ # Configure options
25
+ #
26
+ # @example
27
+ # Github.configure do |c|
28
+ # c.some_option = true
29
+ # end
30
+ #
31
+ # @yield the configuration block
32
+ # @yieldparam configuration [Github::Configuration]
33
+ # the configuration instance
34
+ #
35
+ # @return [nil]
36
+ #
37
+ # @api public
38
+ def configure
39
+ yield configuration
23
40
  end
24
41
 
25
42
  # Alias for Github::Client.new
@@ -63,69 +80,14 @@ module Github
63
80
  super(method_name, include_private)
64
81
  end
65
82
  end
66
-
67
- module ClassMethods
68
- # Requires internal libraries
69
- #
70
- # @param [String] prefix
71
- # the relative path prefix
72
- # @param [Array[String]] libs
73
- # the array of libraries to require
74
- #
75
- # @return [self]
76
- def require_all(prefix, *libs)
77
- libs.each do |lib|
78
- require "#{File.join(prefix, lib)}"
79
- end
80
- end
81
-
82
- # The client configuration
83
- #
84
- # @return [Configuration]
85
- #
86
- # @api public
87
- def configuration
88
- @configuration ||= Configuration.new
89
- end
90
- alias_method :config, :configuration
91
-
92
- # Configure options
93
- #
94
- # @example
95
- # Github.configure do |c|
96
- # c.some_option = true
97
- # end
98
- #
99
- # @yield the configuration block
100
- # @yieldparam configuration [Github::Configuration]
101
- # the configuration instance
102
- #
103
- # @return [nil]
104
- #
105
- # @api public
106
- def configure
107
- yield configuration
108
- end
109
- end
110
-
111
- extend ClassMethods
112
-
113
- require_all LIBDIR,
114
- 'authorization',
115
- 'validations',
116
- 'normalizer',
117
- 'parameter_filter',
118
- 'api',
119
- 'client',
120
- 'pagination',
121
- 'request',
122
- 'response',
123
- 'response_wrapper',
124
- 'error',
125
- 'mime_type',
126
- 'page_links',
127
- 'paged_request',
128
- 'page_iterator',
129
- 'params_hash'
130
-
131
83
  end # Github
84
+
85
+ require_relative 'github_api/api'
86
+ require_relative 'github_api/client'
87
+ require_relative 'github_api/configuration'
88
+ require_relative 'github_api/deprecation'
89
+ require_relative 'github_api/core_ext/array'
90
+ require_relative 'github_api/core_ext/hash'
91
+ require_relative 'github_api/core_ext/ordered_hash'
92
+ require_relative 'github_api/middleware'
93
+ require_relative 'github_api/version'
@@ -1,32 +1,29 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'github_api/configuration'
4
- require 'github_api/mime_type'
5
- require 'github_api/rate_limit'
6
- require 'github_api/core_ext/hash'
7
- require 'github_api/core_ext/array'
8
- require 'github_api/null_encoder'
9
-
10
- require 'github_api/request/verbs'
11
-
12
- require 'github_api/api/actions'
13
- require 'github_api/api/factory'
14
- require 'github_api/api/arguments'
3
+ require_relative 'authorization'
4
+ require_relative 'api/actions'
5
+ require_relative 'api/factory'
6
+ require_relative 'api/arguments'
7
+ require_relative 'configuration'
8
+ require_relative 'constants'
9
+ require_relative 'mime_type'
10
+ require_relative 'null_encoder'
11
+ require_relative 'rate_limit'
12
+ require_relative 'request/verbs'
13
+ require_relative 'validations'
15
14
 
16
15
  module Github
17
16
  # Core class responsible for api interface operations
18
17
  class API
19
- extend Github::ClassMethods
20
-
21
18
  include Constants
22
19
  include Authorization
23
20
  include MimeType
24
- include Request::Verbs
25
21
  include RateLimit
22
+ include Request::Verbs
26
23
 
27
- attr_reader *Github.configuration.property_names
24
+ attr_reader(*Github.configuration.property_names)
28
25
 
29
- attr_accessor *Validations::VALID_API_KEYS
26
+ attr_accessor(*Validations::VALID_API_KEYS)
30
27
 
31
28
  attr_accessor :current_options
32
29
 
@@ -40,6 +37,22 @@ module Github
40
37
  end
41
38
  end
42
39
 
40
+ # Requires internal libraries
41
+ #
42
+ # @param [String] prefix
43
+ # the relative path prefix
44
+ # @param [Array[String]] libs
45
+ # the array of libraries to require
46
+ #
47
+ # @return [self]
48
+ #
49
+ # @api public
50
+ def self.require_all(prefix, *libs)
51
+ libs.each do |lib|
52
+ require "#{File.join(prefix, lib)}"
53
+ end
54
+ end
55
+
43
56
  # Create new API
44
57
  #
45
58
  # @api public
@@ -209,7 +222,7 @@ module Github
209
222
  #
210
223
  # @api private
211
224
  def filter_callbacks(kind, action_name)
212
- matched_callbacks = self.class.send("#{kind}_callbacks").select do |callback|
225
+ self.class.send("#{kind}_callbacks").select do |callback|
213
226
  callback[:only].nil? || callback[:only].include?(action_name)
214
227
  end
215
228
  end
@@ -253,6 +266,10 @@ module Github
253
266
  end
254
267
  end
255
268
 
269
+ def respond_to?(method_name, include_private = false)
270
+ method_name.to_s.start_with?('clear_') || super
271
+ end
272
+
256
273
  # Acts as setter and getter for api requests arguments parsing.
257
274
  #
258
275
  # Returns Arguments instance.
@@ -1,5 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../normalizer'
4
+ require_relative '../parameter_filter'
5
+ require_relative '../params_hash'
6
+ require_relative '../validations'
7
+
3
8
  module Github
4
9
  class API
5
10
  # A class responsible for handilng request arguments
@@ -1,14 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'github_api/api/config/property'
4
- require 'github_api/api/config/property_set'
3
+ require_relative 'config/property'
4
+ require_relative 'config/property_set'
5
5
 
6
6
  module Github
7
-
8
7
  class API
9
8
  # A base class for constructing api configuration
10
9
  class Config
11
-
12
10
  # Defines a property on an object's class or instance
13
11
  #
14
12
  # @example
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'set'
3
4
 
4
5
  module Github
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'oauth2'
4
+
3
5
  module Github
4
6
  module Authorization
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 < API
5
7
  require_all 'github_api/client',
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::Activity < 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::Activity::Events < API
5
7
  # List all public events
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Activity::Feeds < API
5
7
  # List all the feeds available to the authenticated user.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Activity::Notifications < API
5
7
  # List your notifications
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # Repository Starring is a feature that lets users bookmark repositories.
5
7
  # Stars are shown next to repositories to show an approximate level of interest.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  # Watching a Repository registers the user to receive notificactions on new
5
7
  # discussions, as well as events in the user's activity feed.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  # OAuth Authorizations API
5
7
  class Client::Authorizations < API
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Authorizations::App < Client::Authorizations
5
7
  # Get-or-create an authorization for a specific app
@@ -47,7 +49,7 @@ module Github
47
49
  if arguments.client_id
48
50
  begin
49
51
  get_request("/applications/#{arguments.client_id}/tokens/#{arguments.access_token}", params)
50
- rescue Github::Error::NotFound => e
52
+ rescue Github::Error::NotFound
51
53
  nil
52
54
  end
53
55
  else
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::Emojis < API
5
7
  # Lists all the emojis.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::Gists < 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::Gists::Comments < API
5
7
  # List comments on a gist
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::GitData < API
5
7
 
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Github
3
+ require_relative '../../api'
4
4
 
5
+ module Github
5
6
  # Since blobs can be any arbitrary binary data, the input and responses for
6
7
  # the blob api takes an encoding parameter that can be either utf-8 or base64.
7
8
  # If your data cannot be losslessly sent as a UTF-8 string, you can base64 encode it.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::GitData::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
  class Client::GitData::References < 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::GitData::Tags < API
5
7
  # This tags api only deals with tag objects -
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::GitData::Trees < API
5
7