lingfennan-github_api 0.18.2

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 (126) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +741 -0
  4. data/lib/github_api.rb +93 -0
  5. data/lib/github_api/api.rb +398 -0
  6. data/lib/github_api/api/actions.rb +60 -0
  7. data/lib/github_api/api/arguments.rb +253 -0
  8. data/lib/github_api/api/config.rb +105 -0
  9. data/lib/github_api/api/config/property.rb +30 -0
  10. data/lib/github_api/api/config/property_set.rb +120 -0
  11. data/lib/github_api/api/factory.rb +33 -0
  12. data/lib/github_api/authorization.rb +75 -0
  13. data/lib/github_api/client.rb +77 -0
  14. data/lib/github_api/client/activity.rb +31 -0
  15. data/lib/github_api/client/activity/events.rb +233 -0
  16. data/lib/github_api/client/activity/feeds.rb +50 -0
  17. data/lib/github_api/client/activity/notifications.rb +181 -0
  18. data/lib/github_api/client/activity/starring.rb +130 -0
  19. data/lib/github_api/client/activity/watching.rb +176 -0
  20. data/lib/github_api/client/authorizations.rb +142 -0
  21. data/lib/github_api/client/authorizations/app.rb +98 -0
  22. data/lib/github_api/client/emojis.rb +19 -0
  23. data/lib/github_api/client/gists.rb +289 -0
  24. data/lib/github_api/client/gists/comments.rb +100 -0
  25. data/lib/github_api/client/git_data.rb +31 -0
  26. data/lib/github_api/client/git_data/blobs.rb +51 -0
  27. data/lib/github_api/client/git_data/commits.rb +101 -0
  28. data/lib/github_api/client/git_data/references.rb +150 -0
  29. data/lib/github_api/client/git_data/tags.rb +95 -0
  30. data/lib/github_api/client/git_data/trees.rb +113 -0
  31. data/lib/github_api/client/gitignore.rb +57 -0
  32. data/lib/github_api/client/issues.rb +248 -0
  33. data/lib/github_api/client/issues/assignees.rb +77 -0
  34. data/lib/github_api/client/issues/comments.rb +146 -0
  35. data/lib/github_api/client/issues/events.rb +50 -0
  36. data/lib/github_api/client/issues/labels.rb +189 -0
  37. data/lib/github_api/client/issues/milestones.rb +146 -0
  38. data/lib/github_api/client/markdown.rb +62 -0
  39. data/lib/github_api/client/meta.rb +19 -0
  40. data/lib/github_api/client/orgs.rb +127 -0
  41. data/lib/github_api/client/orgs/hooks.rb +182 -0
  42. data/lib/github_api/client/orgs/members.rb +142 -0
  43. data/lib/github_api/client/orgs/memberships.rb +131 -0
  44. data/lib/github_api/client/orgs/projects.rb +57 -0
  45. data/lib/github_api/client/orgs/teams.rb +407 -0
  46. data/lib/github_api/client/projects.rb +83 -0
  47. data/lib/github_api/client/projects/cards.rb +158 -0
  48. data/lib/github_api/client/projects/columns.rb +146 -0
  49. data/lib/github_api/client/pull_requests.rb +195 -0
  50. data/lib/github_api/client/pull_requests/comments.rb +140 -0
  51. data/lib/github_api/client/pull_requests/reviews.rb +158 -0
  52. data/lib/github_api/client/repos.rb +468 -0
  53. data/lib/github_api/client/repos/branches.rb +48 -0
  54. data/lib/github_api/client/repos/branches/protections.rb +75 -0
  55. data/lib/github_api/client/repos/collaborators.rb +84 -0
  56. data/lib/github_api/client/repos/comments.rb +125 -0
  57. data/lib/github_api/client/repos/commits.rb +80 -0
  58. data/lib/github_api/client/repos/contents.rb +246 -0
  59. data/lib/github_api/client/repos/deployments.rb +138 -0
  60. data/lib/github_api/client/repos/downloads.rb +62 -0
  61. data/lib/github_api/client/repos/forks.rb +48 -0
  62. data/lib/github_api/client/repos/hooks.rb +214 -0
  63. data/lib/github_api/client/repos/keys.rb +104 -0
  64. data/lib/github_api/client/repos/merging.rb +47 -0
  65. data/lib/github_api/client/repos/pages.rb +48 -0
  66. data/lib/github_api/client/repos/projects.rb +62 -0
  67. data/lib/github_api/client/repos/pub_sub_hubbub.rb +133 -0
  68. data/lib/github_api/client/repos/releases.rb +189 -0
  69. data/lib/github_api/client/repos/releases/assets.rb +136 -0
  70. data/lib/github_api/client/repos/releases/tags.rb +24 -0
  71. data/lib/github_api/client/repos/statistics.rb +89 -0
  72. data/lib/github_api/client/repos/statuses.rb +91 -0
  73. data/lib/github_api/client/say.rb +25 -0
  74. data/lib/github_api/client/scopes.rb +46 -0
  75. data/lib/github_api/client/search.rb +133 -0
  76. data/lib/github_api/client/search/legacy.rb +111 -0
  77. data/lib/github_api/client/users.rb +117 -0
  78. data/lib/github_api/client/users/emails.rb +65 -0
  79. data/lib/github_api/client/users/followers.rb +115 -0
  80. data/lib/github_api/client/users/keys.rb +104 -0
  81. data/lib/github_api/configuration.rb +70 -0
  82. data/lib/github_api/connection.rb +82 -0
  83. data/lib/github_api/constants.rb +61 -0
  84. data/lib/github_api/core_ext/array.rb +25 -0
  85. data/lib/github_api/core_ext/hash.rb +91 -0
  86. data/lib/github_api/core_ext/ordered_hash.rb +107 -0
  87. data/lib/github_api/deprecation.rb +39 -0
  88. data/lib/github_api/error.rb +32 -0
  89. data/lib/github_api/error/client_error.rb +89 -0
  90. data/lib/github_api/error/service_error.rb +223 -0
  91. data/lib/github_api/ext/faraday.rb +38 -0
  92. data/lib/github_api/mash.rb +7 -0
  93. data/lib/github_api/middleware.rb +37 -0
  94. data/lib/github_api/mime_type.rb +33 -0
  95. data/lib/github_api/normalizer.rb +23 -0
  96. data/lib/github_api/null_encoder.rb +25 -0
  97. data/lib/github_api/page_iterator.rb +138 -0
  98. data/lib/github_api/page_links.rb +63 -0
  99. data/lib/github_api/paged_request.rb +42 -0
  100. data/lib/github_api/pagination.rb +115 -0
  101. data/lib/github_api/parameter_filter.rb +35 -0
  102. data/lib/github_api/params_hash.rb +115 -0
  103. data/lib/github_api/rate_limit.rb +25 -0
  104. data/lib/github_api/request.rb +85 -0
  105. data/lib/github_api/request/basic_auth.rb +36 -0
  106. data/lib/github_api/request/jsonize.rb +54 -0
  107. data/lib/github_api/request/oauth2.rb +44 -0
  108. data/lib/github_api/request/verbs.rb +63 -0
  109. data/lib/github_api/response.rb +48 -0
  110. data/lib/github_api/response/atom_parser.rb +22 -0
  111. data/lib/github_api/response/follow_redirects.rb +140 -0
  112. data/lib/github_api/response/header.rb +87 -0
  113. data/lib/github_api/response/jsonize.rb +28 -0
  114. data/lib/github_api/response/mashify.rb +24 -0
  115. data/lib/github_api/response/raise_error.rb +22 -0
  116. data/lib/github_api/response/xmlize.rb +27 -0
  117. data/lib/github_api/response_wrapper.rb +161 -0
  118. data/lib/github_api/ssl_certs/cacerts.pem +2183 -0
  119. data/lib/github_api/utils/url.rb +63 -0
  120. data/lib/github_api/validations.rb +22 -0
  121. data/lib/github_api/validations/format.rb +26 -0
  122. data/lib/github_api/validations/presence.rb +32 -0
  123. data/lib/github_api/validations/required.rb +21 -0
  124. data/lib/github_api/validations/token.rb +41 -0
  125. data/lib/github_api/version.rb +5 -0
  126. metadata +338 -0
@@ -0,0 +1,136 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../../api'
4
+
5
+ module Github
6
+ # The Release Assets API
7
+ class Client::Repos::Releases::Assets < API
8
+
9
+ VALID_ASSET_PARAM_NAMES = %w[
10
+ name
11
+ label
12
+ content_type
13
+ ].freeze # :nodoc:
14
+
15
+ # List assets for a release
16
+ #
17
+ # @example
18
+ # github = Github.new
19
+ # github.repos.releases.assets.list 'owner', 'repo', 'id'
20
+ # github.repos.releases.assets.list 'owner', 'repo', 'id' { |asset| ... }
21
+ #
22
+ # @api public
23
+ def list(*args)
24
+ arguments(args, required: [:owner, :repo, :id]).params
25
+
26
+ response = get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}/assets", arguments.params)
27
+ return response unless block_given?
28
+ response.each { |el| yield el }
29
+ end
30
+ alias :all :list
31
+
32
+ # Get a single release asset
33
+ #
34
+ # @example
35
+ # github = Github.new
36
+ # github.repos.releases.assets.get 'owner', 'repo', 'id'
37
+ #
38
+ # @api public
39
+ def get(*args)
40
+ arguments(args, required: [:owner, :repo, :id]).params
41
+
42
+ get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}" , arguments.params)
43
+ end
44
+ alias :find :get
45
+
46
+ # Upload a release asset
47
+ #
48
+ # @param [Hash] params
49
+ # @input params [String] :name
50
+ # Required string. The file name of the asset
51
+ # @input params [String] :content_type
52
+ # Required string. The content type of the asset.
53
+ # Example: “application/zip”.
54
+ #
55
+ # @example
56
+ # github = Github.new
57
+ # github.repos.releases.assets.upload 'owner', 'repo', 'id', 'file-path'
58
+ # name: "batman.jpg",
59
+ # content_type: "application/octet-stream"
60
+ #
61
+ # @api public
62
+ def upload(*args)
63
+ arguments(args, required: [:owner, :repo, :id, :filepath]) do
64
+ permit VALID_ASSET_PARAM_NAMES
65
+ end
66
+ params = arguments.params
67
+
68
+ unless type = params['content_type']
69
+ type = infer_media(arguments.filepath)
70
+ end
71
+
72
+ file = Faraday::UploadIO.new(arguments.filepath, type)
73
+ options = {
74
+ headers: { content_type: type },
75
+ endpoint: upload_endpoint,
76
+ query: {'name' => params['name']}
77
+ }
78
+ params['data'] = file.read
79
+ params['options'] = options
80
+
81
+ post_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}/assets", params)
82
+ ensure
83
+ file.close if file
84
+ end
85
+
86
+ # Infer media type of the asset
87
+ #
88
+ def infer_media(filepath)
89
+ require 'mime/types'
90
+ types = MIME::Types.type_for(filepath)
91
+ types.empty? ? 'application/octet-stream' : types.first
92
+ rescue LoadError
93
+ raise Github::Error::UnknownMedia.new(filepath)
94
+ end
95
+
96
+ # Edit a release asset
97
+ #
98
+ # Users with push access to the repository can edit a release asset.
99
+ #
100
+ # @param [Hash] params
101
+ # @input params [String] :name
102
+ # Required. The file name of the asset.
103
+ # @input params [String] :label
104
+ # An alternate short description of the asset.
105
+ # Used in place of the filename.
106
+ #
107
+ # @example
108
+ # github = Github.new
109
+ # github.repos.releases.assets.edit 'owner', 'repo', 'id',
110
+ # name: "foo-1.0.0-osx.zip",
111
+ # label: "Mac binary"
112
+ #
113
+ # @api public
114
+ def edit(*args)
115
+ arguments(args, required: [:owner, :repo, :id]) do
116
+ permit VALID_ASSET_PARAM_NAMES
117
+ end
118
+
119
+ patch_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}", arguments.params)
120
+ end
121
+ alias :update :edit
122
+
123
+ # Delete a release asset
124
+ #
125
+ # @example
126
+ # github = Github.new
127
+ # github.repos.releases.assets.delete 'owner', 'repo', 'id'
128
+ #
129
+ # @api public
130
+ def delete(*args)
131
+ arguments(args, required: [:owner, :repo, :id])
132
+
133
+ delete_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}", arguments.params)
134
+ end
135
+ end # Client::Repos::Releases::Assets
136
+ end # Github
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../../api'
4
+
5
+ module Github
6
+ # The Releases API
7
+ class Client::Repos::Releases::Tags < API
8
+ # Get a published release with the specified tag.
9
+ #
10
+ # @see https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
11
+ #
12
+ # @example
13
+ # github = Github.new
14
+ # github.repos.releases.tags.get 'owner', 'repo', 'tag'
15
+ #
16
+ # @api public
17
+ def get(*args)
18
+ arguments(args, required: [:owner, :repo, :tag]).params
19
+
20
+ get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/tags/#{arguments.tag}" , arguments.params)
21
+ end
22
+ alias_method :find, :get
23
+ end # Client::Repos::Releases::Tags
24
+ end # Github
@@ -0,0 +1,89 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ # The Repository Statistics API allows you to fetch the data that GitHub uses
7
+ # for visualizing different types of repository activity.
8
+ class Client::Repos::Statistics < API
9
+
10
+ # Get contributors list with additions, deletions, and commit counts
11
+ #
12
+ # @example
13
+ # github = Github.new
14
+ # github.repos.stats.contributors user: '...', repo: '...'
15
+ # github.repos.stats.contributors user: '...', repo: '...' { |stat| ... }
16
+ #
17
+ # @api public
18
+ def contributors(*args)
19
+ arguments(args, required: [:user, :repo])
20
+
21
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/stats/contributors", arguments.params)
22
+ return response unless block_given?
23
+ response.each { |el| yield el }
24
+ end
25
+
26
+ # Get the last year of commit activity data
27
+ #
28
+ # Returns the last year of commit activity grouped by week.
29
+ # The days array is a group of commits per day, starting on Sunday
30
+ #
31
+ # @example
32
+ # github = Github.new
33
+ # github.repos.stats.commit_activity user: '...', repo: '...'
34
+ # github.repos.stats.commit_activity user: '...', repo: '...' { |stat| ... }
35
+ #
36
+ # @api public
37
+ def commit_activity(*args)
38
+ arguments(args, required: [:user, :repo])
39
+
40
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/stats/commit_activity", arguments.params)
41
+ return response unless block_given?
42
+ response.each { |el| yield el }
43
+ end
44
+
45
+ # Get the number of additions and deletions per week
46
+ #
47
+ # @example
48
+ # github = Github.new
49
+ # github.repos.stats.code_frequency user: '...', repo: '...'
50
+ # github.repos.stats.code_frequency user: '...', repo: '...' { |stat| ... }
51
+ #
52
+ # @api public
53
+ def code_frequency(*args)
54
+ arguments(args, required: [:user, :repo])
55
+
56
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/stats/code_frequency", arguments.params)
57
+ end
58
+
59
+ # Get the weekly commit count for the repo owner and everyone else
60
+ #
61
+ # @example
62
+ # github = Github.new
63
+ # github.repos.stats.participation user: '...', repo: '...'
64
+ # github.repos.stats.participation user: '...', repo: '...' { |stat| ... }
65
+ #
66
+ # @api public
67
+ def participation(*args)
68
+ arguments(args, required: [:user, :repo])
69
+
70
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/stats/participation", arguments.params)
71
+ end
72
+
73
+ # Get the number of commits per hour in each day
74
+ #
75
+ # @example
76
+ # github = Github.new
77
+ # github.repos.stats.punch_card user: '...', repo: '...'
78
+ # github.repos.stats.punch_card user: '...', repo: '...' { |stat| ... }
79
+ #
80
+ # @api public
81
+ def punch_card(*args)
82
+ arguments(args, required: [:user, :repo])
83
+
84
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/stats/punch_card", arguments.params)
85
+ return response unless block_given?
86
+ response.each { |el| yield el }
87
+ end
88
+ end # Client::Repos::Statistics
89
+ end # Github
@@ -0,0 +1,91 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ # The Status API allows external services to mark commits with a success,
7
+ # failure, error, or pending state, which is then reflected in pull requests
8
+ # involving those commits.
9
+ class Client::Repos::Statuses < API
10
+
11
+ VALID_STATUS_PARAM_NAMES = %w[
12
+ state
13
+ target_url
14
+ description
15
+ context
16
+ ].freeze # :nodoc:
17
+
18
+ REQUIRED_PARAMS = %w[ state ].freeze # :nodoc:
19
+
20
+ # List Statuses for a specific SHA
21
+ #
22
+ # @param [String] :ref
23
+ # Ref to fetch the status for. It can be a SHA, a branch name,
24
+ # or a tag name.
25
+ #
26
+ # @example
27
+ # github = Github.new
28
+ # github.repos.statuses.list 'user-name', 'repo-name', 'ref'
29
+ # github.repos.statuses.list 'user-name', 'repo-name', 'ref' { |status| ... }
30
+ #
31
+ # Get the combined Status for a specific Ref
32
+ #
33
+ # @example
34
+ # github = Github.new
35
+ # github.repos.statuses.list 'user', 'repo', 'ref', combined: true
36
+ #
37
+ # @api public
38
+ def list(*args)
39
+ arguments(args, required: [:user, :repo, :ref])
40
+ params = arguments.params
41
+ user, repo, ref = arguments.user, arguments.repo, arguments.ref
42
+
43
+ response = if params.delete('combined')
44
+ get_request("/repos/#{user}/#{repo}/commits/#{ref}/status", params)
45
+ else
46
+ get_request("/repos/#{user}/#{repo}/commits/#{ref}/statuses", params)
47
+ end
48
+ return response unless block_given?
49
+ response.each { |el| yield el }
50
+ end
51
+ alias :all :list
52
+
53
+ # Create a status
54
+ #
55
+ # @param [Hash] params
56
+ # @input params [String] :state
57
+ # Required. The state of the status. Can be one of pending,
58
+ # success, error, or failure.
59
+ # @input params [String] :target_url
60
+ # The target URL to associate with this status. This URL will
61
+ # be linked from the GitHub UI to allow users to easily see
62
+ # the ‘source’ of the Status.
63
+ #
64
+ # For example, if your Continuous Integration system is posting
65
+ # build status, you would want to provide the deep link for
66
+ # the build output for this specific SHA:
67
+ # http://ci.example.com/user/repo/build/sha.
68
+ # @input params [String] :description
69
+ # A short description of the status
70
+ # @input params [String] :context
71
+ # A string label to differentiate this status from the
72
+ # status of other systems. Default: "default"
73
+ #
74
+ # @example
75
+ # github = Github.new
76
+ # github.repos.statuses.create 'user-name', 'repo-name', 'sha',
77
+ # state: "success",
78
+ # target_url: "http://ci.example.com/johndoe/my-repo/builds/sha",
79
+ # description: "Successful build #3 from origin/master"
80
+ #
81
+ # @api public
82
+ def create(*args)
83
+ arguments(args, required: [:user, :repo, :sha]) do
84
+ permit VALID_STATUS_PARAM_NAMES, recursive: false
85
+ assert_required REQUIRED_PARAMS
86
+ end
87
+
88
+ post_request("/repos/#{arguments.user}/#{arguments.repo}/statuses/#{arguments.sha}", arguments.params)
89
+ end
90
+ end # Client::Repos::Statuses
91
+ 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,133 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../api'
4
+ require_relative '../utils/url'
5
+
6
+ module Github
7
+ # The Search API is optimized to help you find the specific item
8
+ # you're looking for (e.g., a specific user, a specific file
9
+ # in a repository, etc.).
10
+ class Client::Search < API
11
+ include Github::Utils::Url
12
+
13
+ require_all 'github_api/client/search', 'legacy'
14
+
15
+ # Access to Search::Legacy API
16
+ namespace :legacy
17
+
18
+ # Search issues
19
+ #
20
+ # Find issues by state and keyword.
21
+ # (This method returns up to 100 results per page.)
22
+ #
23
+ # @param [Hash] params
24
+ # @option params [String] :q
25
+ # The search terms. This can be any combination of the supported
26
+ # issue search parameters.
27
+ # @option params [String] :sort
28
+ # Optional sort field. One of comments, created, or updated.
29
+ # If not provided, results are sorted by best match.
30
+ # @option params [String] :order
31
+ # The sort order if sort parameter is provided.
32
+ # One of asc or desc. Default: desc
33
+ #
34
+ # @example
35
+ # github = Github.new
36
+ # github.search.issues 'query'
37
+ #
38
+ # @example
39
+ # github.search.issues q: 'query'
40
+ #
41
+ # @api public
42
+ def issues(*args)
43
+ params = arguments(args, required: [:q]).params
44
+ params['q'] ||= arguments.q
45
+
46
+ get_request('/search/issues' , params)
47
+ end
48
+
49
+ # Search repositories
50
+ #
51
+ # Find repositories via various criteria.
52
+ # (This method returns up to 100 results per page.)
53
+ #
54
+ # @param [Hash] params
55
+ # @option params [String] :q
56
+ # The search keywords, as well as any qualifiers.
57
+ # @option params [String] :sort
58
+ # The sort field. One of stars, forks, or updated.
59
+ # Default: results are sorted by best match.
60
+ # @option params [String] :order
61
+ # The sort order if sort parameter is provided.
62
+ # One of asc or desc. Default: desc
63
+ #
64
+ # @example
65
+ # github = Github.new
66
+ # github.search.repos 'query'
67
+ #
68
+ # @example
69
+ # github.search.repos q: 'query'
70
+ #
71
+ # @api public
72
+ def repos(*args)
73
+ params = arguments(args, required: [:q]).params
74
+ params['q'] ||= arguments.q
75
+
76
+ get_request('/search/repositories', arguments.params)
77
+ end
78
+ alias :repositories :repos
79
+
80
+ # Search users
81
+ #
82
+ # Find users by keyword.
83
+ #
84
+ # @param [Hash] params
85
+ # @option params [String] :q
86
+ # The search terms. This can be any combination of the supported
87
+ # issue search parameters.
88
+ # @option params [String] :sort
89
+ # Optional sort field. One of comments, created, or updated.
90
+ # If not provided, results are sorted by best match.
91
+ # @option params [String] :order
92
+ # The sort order if sort parameter is provided.
93
+ # One of asc or desc. Default: desc
94
+ #
95
+ # @example
96
+ # github = Github.new
97
+ # github.search.users q: 'wycats'
98
+ #
99
+ # @api public
100
+ def users(*args)
101
+ params = arguments(args, required: [:q]).params
102
+ params['q'] ||= arguments.q
103
+
104
+ get_request('/search/users', arguments.params)
105
+ end
106
+
107
+ # Find file contents via various criteria.
108
+ # (This method returns up to 100 results per page.)
109
+ #
110
+ # @param [Hash] params
111
+ # @option params [String] :q
112
+ # The search terms. This can be any combination of the supported
113
+ # issue search parameters.
114
+ # @option params [String] :sort
115
+ # Optional sort field. One of comments, created, or updated.
116
+ # If not provided, results are sorted by best match.
117
+ # @option params [String] :order
118
+ # The sort order if sort parameter is provided.
119
+ # One of asc or desc. Default: desc
120
+ #
121
+ # @example
122
+ # github = Github.new
123
+ # github.search.code q: 'wycats'
124
+ #
125
+ # @api public
126
+ def code(*args)
127
+ params = arguments(args, required: [:q]).params
128
+ params['q'] ||= arguments.q
129
+
130
+ get_request('/search/code', params)
131
+ end
132
+ end # Search
133
+ end # Github