github_api2 1.0.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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +770 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.md +741 -0
  5. data/lib/github_api2/api/actions.rb +60 -0
  6. data/lib/github_api2/api/arguments.rb +253 -0
  7. data/lib/github_api2/api/config/property.rb +30 -0
  8. data/lib/github_api2/api/config/property_set.rb +120 -0
  9. data/lib/github_api2/api/config.rb +105 -0
  10. data/lib/github_api2/api/factory.rb +33 -0
  11. data/lib/github_api2/api.rb +398 -0
  12. data/lib/github_api2/authorization.rb +75 -0
  13. data/lib/github_api2/client/activity/events.rb +233 -0
  14. data/lib/github_api2/client/activity/feeds.rb +50 -0
  15. data/lib/github_api2/client/activity/notifications.rb +181 -0
  16. data/lib/github_api2/client/activity/starring.rb +130 -0
  17. data/lib/github_api2/client/activity/watching.rb +176 -0
  18. data/lib/github_api2/client/activity.rb +31 -0
  19. data/lib/github_api2/client/authorizations/app.rb +98 -0
  20. data/lib/github_api2/client/authorizations.rb +142 -0
  21. data/lib/github_api2/client/emojis.rb +19 -0
  22. data/lib/github_api2/client/gists/comments.rb +100 -0
  23. data/lib/github_api2/client/gists.rb +289 -0
  24. data/lib/github_api2/client/git_data/blobs.rb +51 -0
  25. data/lib/github_api2/client/git_data/commits.rb +101 -0
  26. data/lib/github_api2/client/git_data/references.rb +150 -0
  27. data/lib/github_api2/client/git_data/tags.rb +95 -0
  28. data/lib/github_api2/client/git_data/trees.rb +113 -0
  29. data/lib/github_api2/client/git_data.rb +31 -0
  30. data/lib/github_api2/client/gitignore.rb +57 -0
  31. data/lib/github_api2/client/issues/assignees.rb +77 -0
  32. data/lib/github_api2/client/issues/comments.rb +146 -0
  33. data/lib/github_api2/client/issues/events.rb +50 -0
  34. data/lib/github_api2/client/issues/labels.rb +189 -0
  35. data/lib/github_api2/client/issues/milestones.rb +146 -0
  36. data/lib/github_api2/client/issues.rb +248 -0
  37. data/lib/github_api2/client/markdown.rb +62 -0
  38. data/lib/github_api2/client/meta.rb +19 -0
  39. data/lib/github_api2/client/orgs/hooks.rb +182 -0
  40. data/lib/github_api2/client/orgs/members.rb +142 -0
  41. data/lib/github_api2/client/orgs/memberships.rb +131 -0
  42. data/lib/github_api2/client/orgs/projects.rb +57 -0
  43. data/lib/github_api2/client/orgs/teams.rb +407 -0
  44. data/lib/github_api2/client/orgs.rb +127 -0
  45. data/lib/github_api2/client/projects/cards.rb +158 -0
  46. data/lib/github_api2/client/projects/columns.rb +146 -0
  47. data/lib/github_api2/client/projects.rb +83 -0
  48. data/lib/github_api2/client/pull_requests/comments.rb +140 -0
  49. data/lib/github_api2/client/pull_requests/reviews.rb +158 -0
  50. data/lib/github_api2/client/pull_requests.rb +195 -0
  51. data/lib/github_api2/client/repos/branches/protections.rb +75 -0
  52. data/lib/github_api2/client/repos/branches.rb +48 -0
  53. data/lib/github_api2/client/repos/collaborators.rb +84 -0
  54. data/lib/github_api2/client/repos/comments.rb +125 -0
  55. data/lib/github_api2/client/repos/commits.rb +80 -0
  56. data/lib/github_api2/client/repos/contents.rb +263 -0
  57. data/lib/github_api2/client/repos/deployments.rb +138 -0
  58. data/lib/github_api2/client/repos/downloads.rb +62 -0
  59. data/lib/github_api2/client/repos/forks.rb +50 -0
  60. data/lib/github_api2/client/repos/hooks.rb +214 -0
  61. data/lib/github_api2/client/repos/invitations.rb +41 -0
  62. data/lib/github_api2/client/repos/keys.rb +104 -0
  63. data/lib/github_api2/client/repos/merging.rb +47 -0
  64. data/lib/github_api2/client/repos/pages.rb +48 -0
  65. data/lib/github_api2/client/repos/projects.rb +62 -0
  66. data/lib/github_api2/client/repos/pub_sub_hubbub.rb +133 -0
  67. data/lib/github_api2/client/repos/releases/assets.rb +136 -0
  68. data/lib/github_api2/client/repos/releases/tags.rb +24 -0
  69. data/lib/github_api2/client/repos/releases.rb +189 -0
  70. data/lib/github_api2/client/repos/statistics.rb +89 -0
  71. data/lib/github_api2/client/repos/statuses.rb +91 -0
  72. data/lib/github_api2/client/repos.rb +473 -0
  73. data/lib/github_api2/client/say.rb +25 -0
  74. data/lib/github_api2/client/scopes.rb +46 -0
  75. data/lib/github_api2/client/search/legacy.rb +111 -0
  76. data/lib/github_api2/client/search.rb +133 -0
  77. data/lib/github_api2/client/users/emails.rb +65 -0
  78. data/lib/github_api2/client/users/followers.rb +115 -0
  79. data/lib/github_api2/client/users/keys.rb +104 -0
  80. data/lib/github_api2/client/users.rb +117 -0
  81. data/lib/github_api2/client.rb +77 -0
  82. data/lib/github_api2/configuration.rb +70 -0
  83. data/lib/github_api2/connection.rb +82 -0
  84. data/lib/github_api2/constants.rb +61 -0
  85. data/lib/github_api2/core_ext/array.rb +25 -0
  86. data/lib/github_api2/core_ext/hash.rb +91 -0
  87. data/lib/github_api2/deprecation.rb +39 -0
  88. data/lib/github_api2/error/client_error.rb +89 -0
  89. data/lib/github_api2/error/service_error.rb +223 -0
  90. data/lib/github_api2/error.rb +32 -0
  91. data/lib/github_api2/ext/faraday.rb +40 -0
  92. data/lib/github_api2/mash.rb +7 -0
  93. data/lib/github_api2/middleware.rb +37 -0
  94. data/lib/github_api2/mime_type.rb +33 -0
  95. data/lib/github_api2/normalizer.rb +23 -0
  96. data/lib/github_api2/null_encoder.rb +25 -0
  97. data/lib/github_api2/page_iterator.rb +138 -0
  98. data/lib/github_api2/page_links.rb +63 -0
  99. data/lib/github_api2/paged_request.rb +42 -0
  100. data/lib/github_api2/pagination.rb +115 -0
  101. data/lib/github_api2/parameter_filter.rb +35 -0
  102. data/lib/github_api2/params_hash.rb +115 -0
  103. data/lib/github_api2/rate_limit.rb +25 -0
  104. data/lib/github_api2/request/basic_auth.rb +36 -0
  105. data/lib/github_api2/request/jsonize.rb +54 -0
  106. data/lib/github_api2/request/oauth2.rb +45 -0
  107. data/lib/github_api2/request/verbs.rb +63 -0
  108. data/lib/github_api2/request.rb +84 -0
  109. data/lib/github_api2/response/atom_parser.rb +22 -0
  110. data/lib/github_api2/response/follow_redirects.rb +140 -0
  111. data/lib/github_api2/response/header.rb +87 -0
  112. data/lib/github_api2/response/jsonize.rb +28 -0
  113. data/lib/github_api2/response/mashify.rb +24 -0
  114. data/lib/github_api2/response/raise_error.rb +22 -0
  115. data/lib/github_api2/response/xmlize.rb +28 -0
  116. data/lib/github_api2/response.rb +48 -0
  117. data/lib/github_api2/response_wrapper.rb +161 -0
  118. data/lib/github_api2/ssl_certs/cacerts.pem +2183 -0
  119. data/lib/github_api2/utils/url.rb +63 -0
  120. data/lib/github_api2/validations/format.rb +26 -0
  121. data/lib/github_api2/validations/presence.rb +32 -0
  122. data/lib/github_api2/validations/required.rb +21 -0
  123. data/lib/github_api2/validations/token.rb +41 -0
  124. data/lib/github_api2/validations.rb +22 -0
  125. data/lib/github_api2/version.rb +5 -0
  126. data/lib/github_api2.rb +92 -0
  127. metadata +363 -0
@@ -0,0 +1,473 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../api'
4
+
5
+ module Github
6
+ class Client::Repos < API
7
+ # Load all the modules after initializing Repos to avoid superclass mismatch
8
+ require_all 'github_api2/client/repos',
9
+ 'branches',
10
+ 'collaborators',
11
+ 'comments',
12
+ 'commits',
13
+ 'contents',
14
+ 'deployments',
15
+ 'downloads',
16
+ 'forks',
17
+ 'hooks',
18
+ 'invitations',
19
+ 'keys',
20
+ 'merging',
21
+ 'pages',
22
+ 'projects',
23
+ 'pub_sub_hubbub',
24
+ 'releases',
25
+ 'statistics',
26
+ 'statuses'
27
+
28
+ REQUIRED_REPO_OPTIONS = %w[ name ]
29
+
30
+ VALID_REPO_OPTIONS = %w[
31
+ name
32
+ description
33
+ homepage
34
+ private
35
+ has_issues
36
+ has_projects
37
+ has_wiki
38
+ has_downloads
39
+ team_id
40
+ auto_init
41
+ gitignore_template
42
+ default_branch
43
+ ].freeze
44
+
45
+ VALID_REPO_TYPES = %w[ all public private member ].freeze
46
+
47
+ # Access to Repos::Collaborators API
48
+ namespace :collaborators
49
+
50
+ # Access to Repos::Comments API
51
+ namespace :comments
52
+
53
+ # Access to Repos::Commits API
54
+ namespace :commits
55
+
56
+ # Access to Repos::Contents API
57
+ namespace :contents
58
+
59
+ # Access to Repos::Deployments API
60
+ namespace :deployments
61
+
62
+ # Access to Repos::Downloads API
63
+ namespace :downloads
64
+
65
+ # Access to Repos::Forks API
66
+ namespace :forks
67
+
68
+ # Access to Repos::Hooks API
69
+ namespace :hooks
70
+
71
+ # Access to Repos::Invitations API
72
+ namespace :invitations
73
+
74
+ # Access to Repos::Keys API
75
+ namespace :keys
76
+
77
+ # Access to Repos::Merging API
78
+ namespace :merging
79
+
80
+ # Access to Repos::Pages API
81
+ namespace :pages
82
+
83
+ # Access to Repos::Projects API
84
+ namespace :projects
85
+
86
+ # Access to Repos::PubSubHubbub API
87
+ namespace :pubsubhubbub, full_name: :pub_sub_hubbub
88
+
89
+ # Access to Repos::Releases API
90
+ namespace :releases
91
+
92
+ # Access to Repos::Statistics API
93
+ namespace :stats, full_name: :statistics
94
+
95
+ # Access to Repos::Statuses API
96
+ namespace :statuses
97
+
98
+ # Access to Repos::Branches API
99
+ namespace :branches
100
+
101
+ # List repositories for the authenticated user
102
+ #
103
+ # @example
104
+ # github = Github.new oauth_token: '...'
105
+ # github.repos.list
106
+ # github.repos.list { |repo| ... }
107
+ #
108
+ # List all repositories
109
+ #
110
+ # This provides a dump of every repository,
111
+ # in the order that they were created.
112
+ #
113
+ # @param [Hash] params
114
+ # @option params [Integer] :since
115
+ # the integer ID of the last Repository that you've seen.
116
+ #
117
+ # @example
118
+ # github = Github.new
119
+ # github.repos.list :every
120
+ # github.repos.list :every { |repo| ... }
121
+ #
122
+ # List public repositories for the specified user.
123
+ #
124
+ # @example
125
+ # github = Github.new
126
+ # github.repos.list user: 'user-name'
127
+ # github.repos.list user: 'user-name', { |repo| ... }
128
+ #
129
+ # List repositories for the specified organisation.
130
+ #
131
+ # @example
132
+ # github = Github.new
133
+ # github.repos.list org: 'org-name'
134
+ # github.repos.list org: 'org-name', { |repo| ... }
135
+ #
136
+ # @api public
137
+ def list(*args)
138
+ arguments(args) do
139
+ permit %w[ user org type sort direction since ]
140
+ end
141
+ params = arguments.params
142
+ unless params.symbolize_keys[:per_page]
143
+ params.merge!(Pagination.per_page_as_param(current_options[:per_page]))
144
+ end
145
+
146
+ response = if (user_name = params.delete('user') || user)
147
+ get_request("/users/#{user_name}/repos", params)
148
+ elsif (org_name = params.delete('org') || org)
149
+ get_request("/orgs/#{org_name}/repos", params)
150
+ elsif args.map(&:to_s).include?('every')
151
+ get_request('/repositories', params)
152
+ else
153
+ # For authenticated user
154
+ get_request('/user/repos', params)
155
+ end
156
+ return response unless block_given?
157
+ response.each { |el| yield el }
158
+ end
159
+ alias :all :list
160
+
161
+ # Get a repository
162
+ #
163
+ # @example
164
+ # github = Github.new
165
+ # github.repos.get 'user-name', 'repo-name'
166
+ # github.repos.get user: 'user-name', repo: 'repo-name'
167
+ # github.repos(user: 'user-name', repo: 'repo-name').get
168
+ #
169
+ def get(*args)
170
+ arguments(args, required: [:user, :repo])
171
+
172
+ get_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
173
+ end
174
+ alias :find :get
175
+
176
+ # Get a repository
177
+ #
178
+ # @example
179
+ # github = Github.new
180
+ # github.repos.get_by_id 'repo-id'
181
+ # github.repos.get_by_id id: 'repo-id'
182
+ # github.repos(id: 'repo-id').get_by_id
183
+ #
184
+ def get_by_id(*args)
185
+ arguments(args, required: [:id])
186
+
187
+ get_request("/repositories/#{arguments.id}", arguments.params)
188
+ end
189
+ alias :find_by_id :get_by_id
190
+
191
+ # Create a new repository for the authenticated user.
192
+ #
193
+ # @param [Hash] params
194
+ # @option params [String] :name
195
+ # Required string
196
+ # @option params [String] :description
197
+ # Optional string
198
+ # @option params [String] :homepage
199
+ # Optional string
200
+ # @option params [Boolean] :private
201
+ # Optional boolean - true to create a private repository,
202
+ # false to create a public one.
203
+ # @option params [Boolean] :has_issues
204
+ # Optional boolean - true to enable issues for this repository,
205
+ # false to disable them
206
+ # @option params [Boolean] :has_wiki
207
+ # Optional boolean - true to enable the wiki for this repository,
208
+ # false to disable it. Default is true
209
+ # @option params [Boolean] :has_downloads
210
+ # Optional boolean - true to enable downloads for this repository
211
+ # @option params [String] :org
212
+ # Optional string - The organisation in which this
213
+ # repository will be created
214
+ # @option params [Numeric] :team_id
215
+ # Optional number - The id of the team that will be granted
216
+ # access to this repository. This is only valid when creating
217
+ # a repo in an organization
218
+ # @option params [Boolean] :auto_init
219
+ # Optional boolean - true to create an initial commit with
220
+ # empty README. Default is false.
221
+ # @option params [String] :gitignore_template
222
+ # Optional string - Desired language or platform .gitignore
223
+ # template to apply. Use the name of the template without
224
+ # the extension. For example, “Haskell” Ignored if
225
+ # auto_init parameter is not provided.
226
+ #
227
+ # @example
228
+ # github = Github.new
229
+ # github.repos.create "name": 'repo-name'
230
+ # "description": "This is your first repo",
231
+ # "homepage": "https://github.com",
232
+ # "private": false,
233
+ # "has_issues": true,
234
+ # "has_wiki": true,
235
+ # "has_downloads": true
236
+ #
237
+ # Create a new repository in this organisation. The authenticated user
238
+ # must be a member of this organisation
239
+ #
240
+ # @example
241
+ # github = Github.new oauth_token: '...'
242
+ # github.repos.create name: 'repo-name', org: 'organisation-name'
243
+ #
244
+ # @example
245
+ def create(*args)
246
+ arguments(args) do
247
+ assert_required %w[ name ]
248
+ end
249
+ params = arguments.params
250
+
251
+ # Requires authenticated user
252
+ if (org = params.delete('org') || org)
253
+ post_request("/orgs/#{org}/repos", params)
254
+ else
255
+ post_request("/user/repos", params)
256
+ end
257
+ end
258
+
259
+ # Delete a repository
260
+ #
261
+ # Deleting a repository requires admin access.
262
+ # If OAuth is used, the delete_repo scope is required.
263
+ #
264
+ # @example
265
+ # github = Github.new oauth_token: '...'
266
+ # github.repos.delete 'user-name', 'repo-name'
267
+ #
268
+ # @api public
269
+ def delete(*args)
270
+ arguments(args, required: [:user, :repo])
271
+
272
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
273
+ end
274
+ alias :remove :delete
275
+
276
+ # List contributors
277
+ #
278
+ # @param [Hash] params
279
+ # @option params [Boolean] :anon
280
+ # Optional flag. Set to 1 or true to include anonymous contributors.
281
+ #
282
+ # @examples
283
+ # github = Github.new
284
+ # github.repos.contributors 'user-name','repo-name'
285
+ # github.repos.contributors 'user-name','repo-name' { |cont| ... }
286
+ #
287
+ # @api public
288
+ def contributors(*args)
289
+ arguments(args, required: [:user, :repo]) do
290
+ permit %w[ anon ]
291
+ end
292
+
293
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/contributors", arguments.params)
294
+ return response unless block_given?
295
+ response.each { |el| yield el }
296
+ end
297
+ alias :list_contributors :contributors
298
+ alias :contribs :contributors
299
+
300
+ # Edit a repository
301
+ #
302
+ # @param [Hash] params
303
+ # @option params [String] :name
304
+ # Required string
305
+ # @option params [String] :description
306
+ # Optional string
307
+ # @option params [String] :homepage
308
+ # Optional string
309
+ # @option params [Boolean] :private
310
+ # Optional boolean, true to make this a private repository, false to make it a public one
311
+ # @option params [Boolean] :has_issues
312
+ # Optional boolean - true to enable issues for this repository,
313
+ # false to disable them
314
+ # @option params [Boolean] :has_wiki
315
+ # Optional boolean - true to enable the wiki for this repository,
316
+ # false to disable it. Default is true
317
+ # @option params [Boolean] :has_downloads
318
+ # Optional boolean - true to enable downloads for this repository
319
+ # @option params [String] :default_branch
320
+ # Optional string - Update the default branch for this repository.
321
+ #
322
+ # @example
323
+ # github = Github.new
324
+ # github.repos.edit 'user-name', 'repo-name',
325
+ # name: 'hello-world',
326
+ # description: 'This is your first repo',
327
+ # homepage: "https://github.com",
328
+ # public: true, has_issues: true
329
+ #
330
+ def edit(*args)
331
+ arguments(args, required: [:user, :repo]) do
332
+ permit VALID_REPO_OPTIONS
333
+ assert_required %w[ name ]
334
+ end
335
+
336
+ patch_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
337
+ end
338
+
339
+ # Delete a repository
340
+ #
341
+ # Deleting a repository requires admin access.
342
+ # If OAuth is used, the delete_repo scope is required.
343
+ #
344
+ # @example
345
+ # github = Github.new oauth_token: '...'
346
+ # github.repos.delete 'user-name', 'repo-name'
347
+ #
348
+ # @api public
349
+ def delete(*args)
350
+ arguments(args, required: [:user, :repo])
351
+
352
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
353
+ end
354
+ alias :remove :delete
355
+
356
+ # List branches
357
+ #
358
+ # @example
359
+ # github = Github.new
360
+ # github.repos.branches 'user-name', 'repo-name'
361
+ # github.repos(user: 'user-name', repo: 'repo-name').branches
362
+ #
363
+ # @example
364
+ # repos = Github::Repos.new
365
+ # repos.branches 'user-name', 'repo-name'
366
+ #
367
+ # @api public
368
+ # def branches(*args)
369
+ # arguments(args, required: [:user, :repo])
370
+
371
+ # response = get_request("/repos/#{arguments.user}/#{arguments.repo}/branches", arguments.params)
372
+ # return response unless block_given?
373
+ # response.each { |el| yield el }
374
+ # end
375
+ # alias :list_branches :branches
376
+
377
+ # Get branch
378
+ #
379
+ # @example
380
+ # github = Github.new
381
+ # github.repos.branch 'user-name', 'repo-name', 'branch-name'
382
+ # github.repos.branch user: 'user-name', repo: 'repo-name', branch: 'branch-name'
383
+ # github.repos(user: 'user-name', repo: 'repo-name', branch: 'branch-name').branch
384
+ # @api public
385
+ # def branch(*args)
386
+ # arguments(args, required: [:user, :repo, :branch])
387
+
388
+ # get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}", arguments.params)
389
+ # end
390
+
391
+ # List contributors
392
+ #
393
+ # @param [Hash] params
394
+ # @option params [Boolean] :anon
395
+ # Optional flag. Set to 1 or true to include anonymous contributors.
396
+ #
397
+ # @example
398
+ # github = Github.new
399
+ # github.repos.contributors 'user-name','repo-name'
400
+ # github.repos.contributors 'user-name','repo-name' { |cont| ... }
401
+ #
402
+ # @api public
403
+ def contributors(*args)
404
+ arguments(args, required: [:user, :repo]) do
405
+ permit ['anon']
406
+ end
407
+
408
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/contributors", arguments.params)
409
+ return response unless block_given?
410
+ response.each { |el| yield el }
411
+ end
412
+ alias :list_contributors :contributors
413
+ alias :contribs :contributors
414
+
415
+ # List languages
416
+ #
417
+ # @examples
418
+ # github = Github.new
419
+ # github.repos.languages 'user-name', 'repo-name'
420
+ # github.repos.languages 'user-name', 'repo-name' { |lang| ... }
421
+ #
422
+ # @api public
423
+ def languages(*args)
424
+ arguments(args, required: [:user, :repo])
425
+
426
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/languages", arguments.params)
427
+ return response unless block_given?
428
+ response.each { |el| yield el }
429
+ end
430
+ alias :list_languages :languages
431
+
432
+ # List tags
433
+ #
434
+ # @example
435
+ # github = Github.new
436
+ # github.repos.tags 'user-name', 'repo-name'
437
+ # github.repos.tags 'user-name', 'repo-name' { |tag| ... }
438
+ #
439
+ # @api public
440
+ def tags(*args)
441
+ arguments(args, required: [:user, :repo])
442
+
443
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/tags", arguments.params)
444
+ return response unless block_given?
445
+ response.each { |el| yield el }
446
+ end
447
+ alias :list_tags :tags
448
+ alias :repo_tags :tags
449
+ alias :repository_tags :tags
450
+
451
+ # List teams
452
+ #
453
+ # @example
454
+ # github = Github.new
455
+ # github.repos.teams 'user-name', 'repo-name'
456
+ # github.repos.teams 'user-name', 'repo-name' { |team| ... }
457
+ #
458
+ # @example
459
+ # github.repos(user: 'user-name, repo: 'repo-name').teams
460
+ #
461
+ # @api public
462
+ def teams(*args)
463
+ arguments(args, required: [:user, :repo])
464
+
465
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/teams", arguments.params)
466
+ return response unless block_given?
467
+ response.each { |el| yield el }
468
+ end
469
+ alias :list_teams :teams
470
+ alias :repo_teams :teams
471
+ alias :repository_teams :teams
472
+ end # Client::Repos
473
+ end # Github
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../api'
4
+
5
+ module Github
6
+ class Client::Say < API
7
+
8
+ # Generate ASCII octocat with speech bubble.
9
+ #
10
+ # @example
11
+ # Github::Client::Say.new.say "My custom string..."
12
+ #
13
+ # @example
14
+ # github = Github.new
15
+ # github.octocat.say "My custom string..."
16
+ #
17
+ def say(*args)
18
+ params = arguments(*args).params
19
+ params[:s] = args.shift unless args.empty?
20
+ params['raw'] = true
21
+
22
+ get_request('/octocat', params)
23
+ end
24
+ end # Say
25
+ end # Github
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../api'
4
+
5
+ module Github
6
+ class Client::Scopes < API
7
+ # Check what OAuth scopes you have.
8
+ #
9
+ # @see https://developer.github.com/v3/oauth/#scopes
10
+ #
11
+ # @example
12
+ # github = Github.new oauth_token: 'e72e16c7e42f292c6912e7710c838347ae17'
13
+ # github.scopes.all
14
+ #
15
+ # @example
16
+ # github = Github.new
17
+ # github.scopes.list 'e72e16c7e42f292c6912e7710c838347ae17'
18
+ #
19
+ # @example
20
+ # github = Github.new
21
+ # github.scopes.list token: 'e72e16c7e42f292c6912e7710c838347ae17'
22
+ #
23
+ # @api public
24
+ def list(*args)
25
+ arguments(args)
26
+ params = arguments.params
27
+ token = args.shift
28
+
29
+ if token.is_a?(Hash) && !params['token'].nil?
30
+ token = params.delete('token')
31
+ elsif token.nil?
32
+ token = oauth_token
33
+ end
34
+
35
+ if token.nil?
36
+ raise ArgumentError, 'Access token required'
37
+ end
38
+
39
+ headers = { 'Authorization' => "token #{token}" }
40
+ params['headers'] = headers
41
+ response = get_request("/user", params)
42
+ response.headers.oauth_scopes.split(',').map(&:strip)
43
+ end
44
+ alias all list
45
+ end # Client::Scopes
46
+ end # Github
@@ -0,0 +1,111 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Search::Legacy < API
7
+ include Github::Utils::Url
8
+
9
+ # Search issues
10
+ #
11
+ # Find issues by state and keyword.
12
+ #
13
+ # @param [Hash] params
14
+ # @option params [String] :state
15
+ # Indicates the state of the issues to return. Can be either open or closed.
16
+ # @option params [String] :keyword
17
+ # The search term
18
+ #
19
+ # @example
20
+ # github = Github.new
21
+ # github.search.legacy.issues 'owner', 'repo-name', 'open','api'
22
+ # github.search.legacy.issues owner: 'owner', repo: 'repo-name', state: 'open', keyword: 'api'
23
+ #
24
+ # @api public
25
+ def issues(*args)
26
+ required = %w[ owner repo state keyword ]
27
+ arguments(args, required: required)
28
+
29
+ get_request("/legacy/issues/search/#{arguments.owner}/#{arguments.repo}/#{arguments.state}/#{escape_uri(arguments.keyword)}", arguments.params)
30
+ end
31
+
32
+ # Search repositories
33
+ #
34
+ # Find repositories by keyword.
35
+ #
36
+ # @param [Hash] params
37
+ # @option params [String] :keyword
38
+ # The search term
39
+ # @option params [String] :language
40
+ # Filter results by language
41
+ # @option params [String] :start_page
42
+ # The page number to fetch
43
+ # @option params [String] :sort
44
+ # The sort field. One of stars, forks, or updated.
45
+ # Default: results are sorted by best match.
46
+ # @option params [String] :order
47
+ # The sort field. if sort param is provided.
48
+ # Can be either asc or desc.
49
+ #
50
+ # @example
51
+ # github = Github.new
52
+ # github.search.legacy.repos 'api'
53
+ # github.search.legacy.repos keyword: 'api'
54
+ #
55
+ # @api public
56
+ def repos(*args)
57
+ arguments(args, required: [:keyword])
58
+
59
+ get_request("/legacy/repos/search/#{escape_uri(arguments.keyword)}", arguments.params)
60
+ end
61
+ alias :repositories :repos
62
+
63
+ # Search users
64
+ #
65
+ # Find users by keyword.
66
+ #
67
+ # @param [Hash] params
68
+ # @option params [String] :keyword
69
+ # The search term
70
+ # @option params [String] :start_page
71
+ # The page number to fetch
72
+ # @option params [String] :sort
73
+ # The sort field. One of stars, forks, or updated.
74
+ # Default: results are sorted by best match.
75
+ # @option params [String] :order
76
+ # The sort field. if sort param is provided.
77
+ # Can be either asc or desc.
78
+ #
79
+ # @example
80
+ # github = Github.new
81
+ # github.search.legacy.users 'user'
82
+ # github.search.legacy.users keyword: 'user'
83
+ #
84
+ # @api public
85
+ def users(*args)
86
+ arguments(args, required: [:keyword])
87
+
88
+ get_request("/legacy/user/search/#{escape_uri(arguments.keyword)}", arguments.params)
89
+ end
90
+
91
+ # Search email
92
+ #
93
+ # This API call is added for compatibility reasons only. There’s no
94
+ # guarantee that full email searches will always be available.
95
+ #
96
+ # @param [Hash] params
97
+ # @option params [String] :email
98
+ # The email address
99
+ #
100
+ # @example
101
+ # github = Github.new
102
+ # github.search.email 'email-address'
103
+ # github.search.email email: 'email-address'
104
+ #
105
+ # @api public
106
+ def email(*args)
107
+ arguments(args, required: [:email])
108
+ get_request("/legacy/user/email/#{arguments.email}", arguments.params)
109
+ end
110
+ end # Search::Legacy
111
+ end # Github