Skip to content

Commit a253e69

Browse files
committed
Change repository downloads api to use new parser, remove old api methods. Updat docs.
1 parent e211013 commit a253e69

3 files changed

Lines changed: 19 additions & 162 deletions

File tree

lib/github_api/client/repos/downloads.rb

Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -16,96 +16,47 @@ class Client::Repos::Downloads < API
1616

1717
# List downloads for a repository
1818
#
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| ... }
19+
# @example
20+
# github = Github.new
21+
# github.repos.downloads.list 'user-name', 'repo-name'
22+
# github.repos.downloads.list 'user-name', 'repo-name' { |downl| ... }
2323
#
24+
# @api public
2425
def list(*args)
25-
arguments(args, :required => [:user, :repo])
26+
arguments(args, required: [:user, :repo])
2627

27-
response = get_request("/repos/#{user}/#{repo}/downloads", arguments.params)
28+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads", arguments.params)
2829
return response unless block_given?
2930
response.each { |el| yield el }
3031
end
3132
alias :all :list
3233

3334
# Get a single download
3435
#
35-
# = Examples
36-
# github = Github.new
37-
# github.repos.downloads.get 'user-name', 'repo-name', 'download-id'
36+
# @example
37+
# github = Github.new
38+
# github.repos.downloads.get 'user-name', 'repo-name', 'download-id'
3839
#
40+
# @api public
3941
def get(*args)
40-
arguments(args, :required => [:user, :repo, :download_id])
41-
params = arguments.params
42+
arguments(args, required: [:user, :repo, :id])
4243

43-
get_request("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
44+
get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
4445
end
4546
alias :find :get
4647

4748
# Delete download from a repository
4849
#
49-
# = Examples
50-
# github = Github.new
51-
# github.repos.downloads.delete 'user-name', 'repo-name', 'download-id'
50+
# @example
51+
# github = Github.new
52+
# github.repos.downloads.delete 'user-name', 'repo-name', 'download-id'
5253
#
54+
# @api public
5355
def delete(*args)
54-
arguments(args, :required => [:user, :repo, :download_id])
55-
params = arguments.params
56+
arguments(args, required: [:user, :repo, :id])
5657

57-
delete_request("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
58+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
5859
end
5960
alias :remove :delete
60-
61-
# Creating a new download is a two step process.
62-
# You must first create a new download resource using this method.
63-
# Response from this method is to be used in #upload method.
64-
#
65-
# = Inputs
66-
# * <tt>:name</tt> - Required string - name of the file that is being created.
67-
# * <tt>:size</tt> - Required number - size of file in bytes.
68-
# * <tt>:description</tt> - Optional string
69-
# * <tt>:content_type</tt> - Optional string
70-
#
71-
# = Examples
72-
# github = Github.new
73-
# github.repos.downloads.create 'user-name', 'repo-name',
74-
# "name" => "new_file.jpg",
75-
# "size" => 114034,
76-
# "description" => "Latest release",
77-
# "content_type" => "text/plain"
78-
#
79-
def create(*args)
80-
arguments(args, :required => [:user, :repo]) do
81-
sift VALID_DOWNLOAD_PARAM_NAMES
82-
assert_required REQUIRED_PARAMS
83-
end
84-
params = arguments.params
85-
86-
post_request("/repos/#{user}/#{repo}/downloads", params)
87-
end
88-
89-
# Upload a file to Amazon, using the reponse instance from
90-
# Github::Repos::Downloads#create_download. This can be done by passing
91-
# the response object as an argument to upload method.
92-
#
93-
# = Parameters
94-
# * <tt>resource</tt> - Required resource of the create_download call.
95-
# * <tt>:filename</tt> - Required filename, a path to a file location.
96-
#
97-
# = Examples
98-
# resource = github.repos.downloads.create 'user-name', 'repo-name'
99-
#
100-
# github.repos.downloads.upload resource, '/users/octokit/image.jpg'
101-
#
102-
def upload(*args)
103-
arguments(args, :required => [:resource, :filename])
104-
105-
response = Github::S3Uploader.new(resource, filename).send
106-
response.body
107-
end
108-
alias :upload_to_s3 :upload
109-
alias :upload_to_amazon :upload
11061
end # Repos::Downloads
11162
end # Github

spec/github/client/repos/downloads/create_spec.rb

Lines changed: 0 additions & 63 deletions
This file was deleted.

spec/github/client/repos/downloads/upload_spec.rb

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)