github_api 0.4.11 → 0.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.md +76 -72
  2. data/features/cassettes/gists/starred.yml +48 -0
  3. data/features/cassettes/pagination/repos/commits/list.yml +193 -0
  4. data/features/cassettes/pagination/repos/commits/next.yml +183 -0
  5. data/features/cassettes/pagination/repos/diff/next.yml +45 -0
  6. data/features/cassettes/pagination/repos/list.yml +176 -0
  7. data/features/cassettes/pagination/repos/list/next.yml +222 -0
  8. data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
  9. data/features/cassettes/repos/list.yml +92 -0
  10. data/features/error_codes.feature +1 -1
  11. data/features/gists.feature +12 -3
  12. data/features/gists/comments.feature +3 -3
  13. data/features/github_api.feature +13 -2
  14. data/features/pagination.feature +40 -39
  15. data/features/repos.feature +2 -2
  16. data/features/step_definitions/common_steps.rb +12 -0
  17. data/features/step_definitions/github_api_steps.rb +12 -1
  18. data/lib/github_api.rb +1 -1
  19. data/lib/github_api/api.rb +4 -2
  20. data/lib/github_api/api_factory.rb +11 -5
  21. data/lib/github_api/authorizations.rb +23 -32
  22. data/lib/github_api/client.rb +1 -0
  23. data/lib/github_api/events.rb +38 -38
  24. data/lib/github_api/filter.rb +1 -1
  25. data/lib/github_api/gists.rb +47 -42
  26. data/lib/github_api/gists/comments.rb +77 -84
  27. data/lib/github_api/git_data.rb +25 -6
  28. data/lib/github_api/git_data/blobs.rb +48 -45
  29. data/lib/github_api/git_data/commits.rb +76 -73
  30. data/lib/github_api/git_data/references.rb +137 -118
  31. data/lib/github_api/git_data/tags.rb +74 -70
  32. data/lib/github_api/git_data/trees.rb +88 -85
  33. data/lib/github_api/issues.rb +43 -31
  34. data/lib/github_api/issues/comments.rb +116 -119
  35. data/lib/github_api/issues/events.rb +20 -19
  36. data/lib/github_api/issues/labels.rb +200 -197
  37. data/lib/github_api/issues/milestones.rb +137 -134
  38. data/lib/github_api/orgs.rb +27 -23
  39. data/lib/github_api/orgs/members.rb +105 -108
  40. data/lib/github_api/orgs/teams.rb +236 -237
  41. data/lib/github_api/paged_request.rb +1 -1
  42. data/lib/github_api/pull_requests.rb +40 -42
  43. data/lib/github_api/pull_requests/comments.rb +140 -143
  44. data/lib/github_api/repos.rb +101 -67
  45. data/lib/github_api/repos/collaborators.rb +64 -68
  46. data/lib/github_api/repos/commits.rb +50 -39
  47. data/lib/github_api/repos/downloads.rb +107 -110
  48. data/lib/github_api/repos/forks.rb +38 -39
  49. data/lib/github_api/repos/hooks.rb +161 -167
  50. data/lib/github_api/repos/keys.rb +86 -86
  51. data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
  52. data/lib/github_api/repos/watching.rb +80 -82
  53. data/lib/github_api/request.rb +5 -9
  54. data/lib/github_api/users.rb +26 -16
  55. data/lib/github_api/users/emails.rb +47 -47
  56. data/lib/github_api/users/followers.rb +85 -86
  57. data/lib/github_api/users/keys.rb +73 -75
  58. data/lib/github_api/validations.rb +25 -0
  59. data/lib/github_api/validations/format.rb +23 -0
  60. data/lib/github_api/validations/presence.rb +25 -0
  61. data/lib/github_api/validations/required.rb +21 -0
  62. data/lib/github_api/validations/token.rb +41 -0
  63. data/lib/github_api/version.rb +3 -3
  64. data/spec/fixtures/repos/commit_comparison.json +112 -0
  65. data/spec/github/api_factory_spec.rb +17 -1
  66. data/spec/github/authorizations_spec.rb +36 -34
  67. data/spec/github/gists/comments_spec.rb +39 -45
  68. data/spec/github/gists_spec.rb +50 -53
  69. data/spec/github/git_data/blobs_spec.rb +27 -20
  70. data/spec/github/git_data/commits_spec.rb +20 -19
  71. data/spec/github/git_data/references_spec.rb +83 -46
  72. data/spec/github/git_data/tags_spec.rb +16 -15
  73. data/spec/github/git_data/trees_spec.rb +20 -19
  74. data/spec/github/git_data_spec.rb +10 -1
  75. data/spec/github/issues/comments_spec.rb +78 -68
  76. data/spec/github/issues/events_spec.rb +42 -34
  77. data/spec/github/issues/labels_spec.rb +89 -101
  78. data/spec/github/issues/milestones_spec.rb +76 -54
  79. data/spec/github/issues_spec.rb +53 -57
  80. data/spec/github/orgs/members_spec.rb +64 -49
  81. data/spec/github/orgs/teams_spec.rb +112 -101
  82. data/spec/github/orgs_spec.rb +41 -31
  83. data/spec/github/paged_request_spec.rb +6 -5
  84. data/spec/github/pull_requests/comments_spec.rb +39 -44
  85. data/spec/github/pull_requests_spec.rb +32 -48
  86. data/spec/github/repos/collaborators_spec.rb +40 -29
  87. data/spec/github/repos/commits_spec.rb +108 -64
  88. data/spec/github/repos/downloads_spec.rb +46 -45
  89. data/spec/github/repos/forks_spec.rb +23 -24
  90. data/spec/github/repos/hooks_spec.rb +69 -71
  91. data/spec/github/repos/keys_spec.rb +39 -34
  92. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
  93. data/spec/github/repos/watching_spec.rb +31 -33
  94. data/spec/github/repos_spec.rb +74 -83
  95. data/spec/github/request_spec.rb +31 -2
  96. data/spec/github/users/emails_spec.rb +19 -17
  97. data/spec/github/users/followers_spec.rb +30 -28
  98. data/spec/github/users/keys_spec.rb +37 -33
  99. data/spec/github/users_spec.rb +124 -125
  100. data/spec/github/validations/format_spec.rb +42 -0
  101. data/spec/github/validations/presence_spec.rb +18 -0
  102. data/spec/github/validations/required_spec.rb +28 -0
  103. data/spec/github/validations/token_spec.rb +19 -0
  104. data/spec/github/validations_spec.rb +23 -0
  105. metadata +33 -10
  106. data/features/cassettes/pagination/repos.yml +0 -177
  107. data/features/cassettes/pagination/repos/next.yml +0 -177
  108. data/lib/github_api/validation.rb +0 -53
  109. data/spec/github/validation_spec.rb +0 -62
@@ -1,8 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github
4
- class Repos
5
- module Commits
4
+ class Repos::Commits < API
6
5
 
7
6
  REQUIRED_COMMENT_PARAMS = %w[
8
7
  body
@@ -12,6 +11,23 @@ module Github
12
11
  position
13
12
  ].freeze
14
13
 
14
+ # Compares two commits
15
+ #
16
+ # = Examples
17
+ # github = Github.new
18
+ # github.repos.commits.compare
19
+ # 'user-name',
20
+ # 'repo-name',
21
+ # 'v0.4.8',
22
+ # 'master'
23
+ #
24
+ def compare(user_name, repo_name, base, head, params={})
25
+ _validate_presence_of base, head
26
+ _normalize_params_keys(params)
27
+
28
+ get_request("/repos/#{user_name}/#{repo_name}/compare/#{base}...#{head}", params)
29
+ end
30
+
15
31
  # Creates a commit comment
16
32
  #
17
33
  # = Inputs
@@ -22,8 +38,8 @@ module Github
22
38
  # * <tt>:position</tt> - Required number - Line index in the diff to comment on.
23
39
  #
24
40
  # = Examples
25
- # @github = Github.new
26
- # @github.repos.create_comment 'user-name', 'repo-name', 'sha-key',
41
+ # github = Github.new
42
+ # github.repos.commits.create_comment 'user-name', 'repo-name', 'sha-key',
27
43
  # "body" => "Nice change",
28
44
  # "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
29
45
  # "line" => 1,
@@ -40,15 +56,14 @@ module Github
40
56
 
41
57
  _validate_inputs(REQUIRED_COMMENT_PARAMS, params)
42
58
 
43
- post("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
59
+ post_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
44
60
  end
45
- alias :create_commit_comment :create_comment
46
61
 
47
62
  # Deletes a commit comment
48
63
  #
49
64
  # = Examples
50
- # @github = Github.new
51
- # @github.repos.delete_comment 'user-name', 'repo-name', 'comment-id'
65
+ # github = Github.new
66
+ # github.repos.commits.delete_comment 'user-name', 'repo-name', 'comment-id'
52
67
  #
53
68
  def delete_comment(user_name, repo_name, comment_id, params={})
54
69
  _update_user_repo_params(user_name, repo_name)
@@ -56,9 +71,8 @@ module Github
56
71
  _validate_presence_of comment_id
57
72
  _normalize_params_keys(params)
58
73
 
59
- delete("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
74
+ delete_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
60
75
  end
61
- alias :delete_commit_comment :delete_comment
62
76
 
63
77
  # List commits on a repository
64
78
  #
@@ -67,37 +81,35 @@ module Github
67
81
  # * <tt>:path</tt> Optional string. Only commits containing this file path will be returned
68
82
  #
69
83
  # = Examples
70
- # @github = Github.new
71
- # @github.repos.commits 'user-name', 'repo-name', :sha => '...'
72
- # @github.repos.commits 'user-name', 'repo-name', :sha => '...' { |commit| ... }
84
+ # github = Github.new
85
+ # github.repos.commits.list 'user-name', 'repo-name', :sha => '...'
86
+ # github.repos.commits.list 'user-name', 'repo-name', :sha => '...' { |commit| ... }
73
87
  #
74
- def commits(user_name=nil, repo_name=nil, params={})
88
+ def list(user_name, repo_name, params={})
75
89
  _update_user_repo_params(user_name, repo_name)
76
90
  _validate_user_repo_params(user, repo) unless user? && repo?
77
91
  _normalize_params_keys(params)
78
92
  _filter_params_keys(%w[ sha path], params)
79
93
 
80
- response = get("/repos/#{user}/#{repo}/commits", params)
94
+ response = get_request("/repos/#{user}/#{repo}/commits", params)
81
95
  return response unless block_given?
82
96
  response.each { |el| yield el }
83
97
  end
84
- alias :list_commits :commits
85
- alias :list_repo_commits :commits
86
- alias :list_repository_commits :commits
98
+ alias :all :list
87
99
 
88
100
  # List commit comments for a repository
89
101
  #
90
102
  # = Examples
91
- # @github = Github.new
92
- # @github.repos.repo_comments 'user-name', 'repo-name'
93
- # @github.repos.repo_comments 'user-name', 'repo-name' { |com| ... }
103
+ # github = Github.new
104
+ # github.repos.commits.repo_comments 'user-name', 'repo-name'
105
+ # github.repos.commits.repo_comments 'user-name', 'repo-name' { |com| ... }
94
106
  #
95
- def repo_comments(user_name=nil, repo_name=nil, params={})
107
+ def repo_comments(user_name, repo_name, params={})
96
108
  _update_user_repo_params(user_name, repo_name)
97
109
  _validate_user_repo_params(user, repo) unless user? && repo?
98
110
  _normalize_params_keys(params)
99
111
 
100
- response = get("/repos/#{user}/#{repo}/comments", params)
112
+ response = get_request("/repos/#{user}/#{repo}/comments", params)
101
113
  return response unless block_given?
102
114
  response.each { |el| yield el }
103
115
  end
@@ -107,8 +119,8 @@ module Github
107
119
  # List comments for a single commit
108
120
  #
109
121
  # = Examples
110
- # @github = Github.new
111
- # @github.repos.commit_comments 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed695e2e4193db5e'
122
+ # github = Github.new
123
+ # github.repos.commits.commit_comments 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed695e2e4193db5e'
112
124
  #
113
125
  def commit_comments(user_name, repo_name, sha, params={})
114
126
  _update_user_repo_params(user_name, repo_name)
@@ -116,7 +128,7 @@ module Github
116
128
  _validate_presence_of sha
117
129
  _normalize_params_keys(params)
118
130
 
119
- response = get("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
131
+ response = get_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
120
132
  return response unless block_given?
121
133
  response.each { |el| yield el }
122
134
  end
@@ -126,23 +138,23 @@ module Github
126
138
  #
127
139
  # = Examples
128
140
  # @github = Github.new
129
- # @github.repos.commit 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
141
+ # @github.repos.commits.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
130
142
  #
131
- def commit(user_name, repo_name, sha, params={})
143
+ def get(user_name, repo_name, sha, params={})
132
144
  _update_user_repo_params(user_name, repo_name)
133
145
  _validate_user_repo_params(user, repo) unless user? && repo?
134
146
  _validate_presence_of sha
135
147
  _normalize_params_keys(params)
136
148
 
137
- get("/repos/#{user}/#{repo}/commits/#{sha}", params)
149
+ get_request("/repos/#{user}/#{repo}/commits/#{sha}", params)
138
150
  end
139
- alias :get_commit :commit
151
+ alias :find :get
140
152
 
141
153
  # Gets a single commit comment
142
154
  #
143
155
  # = Examples
144
- # @github = Github.new
145
- # @github.repos.commit_comment 'user-name', 'repo-name', 'comment-id'
156
+ # github = Github.new
157
+ # github.repos.commits.commit_comment 'user-name', 'repo-name', 'comment-id'
146
158
  #
147
159
  def commit_comment(user_name, repo_name, comment_id, params={})
148
160
  _update_user_repo_params(user_name, repo_name)
@@ -150,7 +162,7 @@ module Github
150
162
  _validate_presence_of comment_id
151
163
  _normalize_params_keys(params)
152
164
 
153
- get("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
165
+ get_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
154
166
  end
155
167
  alias :get_commit_comment :commit_comment
156
168
 
@@ -160,9 +172,9 @@ module Github
160
172
  # * <tt>:body</tt> - Required string.
161
173
  #
162
174
  # = Examples
163
- # @github = Github.new
164
- # @github.repos.update_comment 'user-name', 'repo-name', 'comment-id',
165
- # "body" => "Nice change"
175
+ # github = Github.new
176
+ # github.repos.commits.update_comment 'user-name', 'repo-name',
177
+ # 'comment-id', "body" => "Nice change"
166
178
  #
167
179
  def update_comment(user_name, repo_name, comment_id, params={})
168
180
  _update_user_repo_params(user_name, repo_name)
@@ -172,9 +184,8 @@ module Github
172
184
  _normalize_params_keys(params)
173
185
  _validate_inputs(%w[ body ], params)
174
186
 
175
- patch("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
187
+ patch_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
176
188
  end
177
189
 
178
- end # Commits
179
- end # Repos
190
+ end # Repos::Commits
180
191
  end # Github
@@ -3,114 +3,111 @@
3
3
  require 'github_api/s3_uploader'
4
4
 
5
5
  module Github
6
- class Repos
7
- module Downloads
8
-
9
- REQUIRED_PARAMS = %w[ name size ]
10
-
11
- VALID_DOWNLOAD_PARAM_NAMES = %w[
12
- name
13
- size
14
- description
15
- content_type
16
- ].freeze
17
-
18
- # List downloads for a repository
19
- #
20
- # = Examples
21
- # @github = Github.new
22
- # @github.repos.downloads 'user-name', 'repo-name'
23
- # @github.repos.downloads 'user-name', 'repo-name' { |downl| ... }
24
- #
25
- def downloads(user_name=nil, repo_name=nil, params={})
26
- _update_user_repo_params(user_name, repo_name)
27
- _validate_user_repo_params(user, repo) unless user? && repo?
28
- _normalize_params_keys(params)
29
-
30
- response = get("/repos/#{user}/#{repo}/downloads", params)
31
- return response unless block_given?
32
- response.each { |el| yield el }
33
- end
34
- alias :list_downloads :downloads
35
- alias :get_downloads :downloads
36
-
37
- # Get a single download
38
- #
39
- # = Examples
40
- # @github = Github.new
41
- # @github.repos.download 'user-name', 'repo-name'
42
- #
43
- def download(user_name, repo_name, download_id, params={})
44
- _update_user_repo_params(user_name, repo_name)
45
- _validate_user_repo_params(user, repo) unless user? && repo?
46
- _validate_presence_of download_id
47
- _normalize_params_keys(params)
48
-
49
- get("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
50
- end
51
- alias :get_download :download
52
-
53
- # Delete download from a repository
54
- #
55
- # = Examples
56
- # @github = Github.new
57
- # @github.repos.delete_download 'user-name', 'repo-name', 'download-id'
58
- #
59
- def delete_download(user_name, repo_name, download_id, params={})
60
- _update_user_repo_params(user_name, repo_name)
61
- _validate_user_repo_params(user, repo) unless user? && repo?
62
- _validate_presence_of download_id
63
- _normalize_params_keys(params)
64
-
65
- delete("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
66
- end
67
-
68
- # Creating a new download is a two step process.
69
- # You must first create a new download resource using this method.
70
- # Response from this method is to be used in #upload method.
71
- #
72
- # = Inputs
73
- # * <tt>:name</tt> - Required string - name of the file that is being created.
74
- # * <tt>:size</tt> - Required number - size of file in bytes.
75
- # * <tt>:description</tt> - Optional string
76
- # * <tt>:content_type</tt> - Optional string
77
- #
78
- # = Examples
79
- # @github = Github.new
80
- # @github.repos.create_download 'user-name', 'repo-name',
81
- # "name" => "new_file.jpg",
82
- # "size" => 114034,
83
- # "description" => "Latest release",
84
- # "content_type" => "text/plain"
85
- #
86
- def create_download(user_name=nil, repo_name=nil, params={})
87
- _update_user_repo_params(user_name, repo_name)
88
- _validate_user_repo_params(user, repo) unless user? && repo?
89
-
90
- _normalize_params_keys(params)
91
- _filter_params_keys(VALID_DOWNLOAD_PARAM_NAMES, params)
92
- _validate_inputs(REQUIRED_PARAMS, params)
93
-
94
- post("/repos/#{user}/#{repo}/downloads", params)
95
- end
96
-
97
- # Upload a file to Amazon, using the reponse instance from
98
- # Github::Repos::Downloads#create_download. This can be done by passing
99
- # the response object as an argument to upload method.
100
- #
101
- # = Parameters
102
- # * <tt>resource</tt> - Required resource of the create_download call.
103
- # * <tt>:filename</tt> - Required filename, a path to a file location.
104
- #
105
- def upload(resource, filename)
106
- _validate_presence_of resource, filename
107
-
108
- response = Github::S3Uploader.new(resource, filename).send
109
- response.body
110
- end
111
- alias :upload_to_s3 :upload
112
- alias :upload_to_amazon :upload
113
-
114
- end # Downloads
115
- end # Repos
6
+ class Repos::Downloads < API
7
+
8
+ REQUIRED_PARAMS = %w[ name size ]
9
+
10
+ VALID_DOWNLOAD_PARAM_NAMES = %w[
11
+ name
12
+ size
13
+ description
14
+ content_type
15
+ ].freeze
16
+
17
+ # List downloads for a repository
18
+ #
19
+ # = Examples
20
+ # github = Github.new
21
+ # github.repos.downloads.list 'user-name', 'repo-name'
22
+ # github.repos.downloads.list 'user-name', 'repo-name' { |downl| ... }
23
+ #
24
+ def list(user_name, repo_name, params={})
25
+ _update_user_repo_params(user_name, repo_name)
26
+ _validate_user_repo_params(user, repo) unless user? && repo?
27
+ _normalize_params_keys(params)
28
+
29
+ response = get_request("/repos/#{user}/#{repo}/downloads", params)
30
+ return response unless block_given?
31
+ response.each { |el| yield el }
32
+ end
33
+ alias :all :list
34
+
35
+ # Get a single download
36
+ #
37
+ # = Examples
38
+ # github = Github.new
39
+ # github.repos.downloads.get 'user-name', 'repo-name', 'download-id'
40
+ #
41
+ def get(user_name, repo_name, download_id, params={})
42
+ _update_user_repo_params(user_name, repo_name)
43
+ _validate_user_repo_params(user, repo) unless user? && repo?
44
+ _validate_presence_of download_id
45
+ _normalize_params_keys(params)
46
+
47
+ get_request("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
48
+ end
49
+ alias :find :get
50
+
51
+ # Delete download from a repository
52
+ #
53
+ # = Examples
54
+ # github = Github.new
55
+ # github.repos.downloads.delete 'user-name', 'repo-name', 'download-id'
56
+ #
57
+ def delete(user_name, repo_name, download_id, params={})
58
+ _update_user_repo_params(user_name, repo_name)
59
+ _validate_user_repo_params(user, repo) unless user? && repo?
60
+ _validate_presence_of download_id
61
+ _normalize_params_keys(params)
62
+
63
+ delete_request("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
64
+ end
65
+
66
+ # Creating a new download is a two step process.
67
+ # You must first create a new download resource using this method.
68
+ # Response from this method is to be used in #upload method.
69
+ #
70
+ # = Inputs
71
+ # * <tt>:name</tt> - Required string - name of the file that is being created.
72
+ # * <tt>:size</tt> - Required number - size of file in bytes.
73
+ # * <tt>:description</tt> - Optional string
74
+ # * <tt>:content_type</tt> - Optional string
75
+ #
76
+ # = Examples
77
+ # github = Github.new
78
+ # github.repos.downloads.create 'user-name', 'repo-name',
79
+ # "name" => "new_file.jpg",
80
+ # "size" => 114034,
81
+ # "description" => "Latest release",
82
+ # "content_type" => "text/plain"
83
+ #
84
+ def create(user_name, repo_name, params={})
85
+ _update_user_repo_params(user_name, repo_name)
86
+ _validate_user_repo_params(user, repo) unless user? && repo?
87
+
88
+ _normalize_params_keys(params)
89
+ _filter_params_keys(VALID_DOWNLOAD_PARAM_NAMES, params)
90
+ _validate_inputs(REQUIRED_PARAMS, params)
91
+
92
+ post_request("/repos/#{user}/#{repo}/downloads", params)
93
+ end
94
+
95
+ # Upload a file to Amazon, using the reponse instance from
96
+ # Github::Repos::Downloads#create_download. This can be done by passing
97
+ # the response object as an argument to upload method.
98
+ #
99
+ # = Parameters
100
+ # * <tt>resource</tt> - Required resource of the create_download call.
101
+ # * <tt>:filename</tt> - Required filename, a path to a file location.
102
+ #
103
+ def upload(resource, filename)
104
+ _validate_presence_of resource, filename
105
+
106
+ response = Github::S3Uploader.new(resource, filename).send
107
+ response.body
108
+ end
109
+ alias :upload_to_s3 :upload
110
+ alias :upload_to_amazon :upload
111
+
112
+ end # Repos::Downloads
116
113
  end # Github
@@ -1,48 +1,47 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github
4
- class Repos
5
- module Forks
4
+ class Repos::Forks < API
6
5
 
7
- # List repository forks
8
- #
9
- # = Examples
10
- # @github = Github.new
11
- # @github.repos.forks 'user-name', 'repo-name'
12
- # @github.repos.forks 'user-name', 'repo-name' { |hook| ... }
13
- #
14
- def forks(user_name=nil, repo_name=nil, params = {})
15
- _update_user_repo_params(user_name, repo_name)
16
- _validate_user_repo_params(user, repo) unless user? && repo?
17
- _normalize_params_keys(params)
6
+ # List repository forks
7
+ #
8
+ # = Parameters
9
+ # * <tt>:sort</tt> - newest, oldest, watchers, default: newest
10
+ #
11
+ # = Examples
12
+ # github = Github.new
13
+ # github.repos.forks.list 'user-name', 'repo-name'
14
+ # github.repos.forks.list 'user-name', 'repo-name' { |hook| ... }
15
+ #
16
+ def list(user_name, repo_name, params = {})
17
+ _update_user_repo_params(user_name, repo_name)
18
+ _validate_user_repo_params(user, repo) unless user? && repo?
19
+ _normalize_params_keys(params)
18
20
 
19
- response = get("/repos/#{user}/#{repo}/forks", params)
20
- return response unless block_given?
21
- response.each { |el| yield el }
22
- end
23
- alias :repo_forks :forks
24
- alias :repository_forks :forks
21
+ response = get_request("/repos/#{user}/#{repo}/forks", params)
22
+ return response unless block_given?
23
+ response.each { |el| yield el }
24
+ end
25
+ alias :all :list
25
26
 
26
- # Create a fork for the authenticated user
27
- #
28
- # = Inputs
29
- # * <tt>:org</tt> - Optional string - the name of the service that is being called.
30
- #
31
- # = Examples
32
- # @github = Github.new
33
- # @github.repos.create_fork 'user-name', 'repo-name',
34
- # "org" => "github"
35
- #
36
- def create_fork(user_name=nil, repo_name=nil, params={})
37
- _update_user_repo_params(user_name, repo_name)
38
- _validate_user_repo_params(user, repo) unless user? && repo?
27
+ # Create a fork for the authenticated user
28
+ #
29
+ # = Inputs
30
+ # * <tt>:org</tt> - Optional string - the name of the service that is being called.
31
+ #
32
+ # = Examples
33
+ # github = Github.new
34
+ # github.repos.forks.create 'user-name', 'repo-name',
35
+ # "org" => "github"
36
+ #
37
+ def create(user_name, repo_name, params={})
38
+ _update_user_repo_params(user_name, repo_name)
39
+ _validate_user_repo_params(user, repo) unless user? && repo?
40
+ _normalize_params_keys(params)
41
+ _filter_params_keys(%w[ org ], params)
39
42
 
40
- _normalize_params_keys(params)
41
- _filter_params_keys(%w[ org ], params)
43
+ post_request("/repos/#{user}/#{repo}/forks", params)
44
+ end
42
45
 
43
- post("/repos/#{user}/#{repo}/forks", params)
44
- end
45
-
46
- end # Forks
47
- end # Repos
46
+ end # Repos::Forks
48
47
  end # Github