Module: Octokit::Client::Releases
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/releases.rb
Overview
Methods for the Releases API
Instance Method Summary collapse
-
#create_release(repo, tag_name, options = {}) ⇒ Sawyer::Resource
Create a release.
-
#delete_release(url, options = {}) ⇒ Boolean
Delete a release.
-
#delete_release_asset(asset_url, options = {}) ⇒ Boolean
Delete a release asset.
-
#latest_release(repo, options = {}) ⇒ Sawyer::Resource
Get the latest release.
-
#release(url, options = {}) ⇒ Sawyer::Resource
Get a release.
-
#release_asset(asset_url, options = {}) ⇒ Sawyer::Resource
Get a single release asset.
-
#release_assets(release_url, options = {}) ⇒ Array<Sawyer::Resource>
List release assets.
-
#release_for_tag(repo, tag_name, options = {}) ⇒ Sawyer::Resource
Get the release for a given tag.
-
#releases(repo, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_releases)
List releases for a repository.
-
#update_release(url, options = {}) ⇒ Sawyer::Resource
(also: #edit_release)
Update a release.
-
#update_release_asset(asset_url, options = {}) ⇒ Sawyer::Resource
(also: #edit_release_asset)
Update a release asset.
-
#upload_asset(release_url, path_or_file, options = {}) ⇒ Sawyer::Resource
Upload a release asset.
Instance Method Details
#create_release(repo, tag_name, options = {}) ⇒ Sawyer::Resource
Create a release
30 31 32 33 |
# File 'lib/octokit/client/releases.rb', line 30 def create_release(repo, tag_name, = {}) opts = .merge(:tag_name => tag_name) post "#{Repository.path repo}/releases", opts end |
#delete_release(url, options = {}) ⇒ Boolean
Delete a release
64 65 66 |
# File 'lib/octokit/client/releases.rb', line 64 def delete_release(url, = {}) boolean_from_response(:delete, url, ) end |
#delete_release_asset(asset_url, options = {}) ⇒ Boolean
Delete a release asset
126 127 128 |
# File 'lib/octokit/client/releases.rb', line 126 def delete_release_asset(asset_url, = {}) boolean_from_response(:delete, asset_url, ) end |
#latest_release(repo, options = {}) ⇒ Sawyer::Resource
Get the latest release
145 146 147 |
# File 'lib/octokit/client/releases.rb', line 145 def latest_release(repo, = {}) get "#{Repository.path repo}/releases/latest", end |
#release(url, options = {}) ⇒ Sawyer::Resource
Get a release
40 41 42 |
# File 'lib/octokit/client/releases.rb', line 40 def release(url, = {}) get url, end |
#release_asset(asset_url, options = {}) ⇒ Sawyer::Resource
Get a single release asset
105 106 107 |
# File 'lib/octokit/client/releases.rb', line 105 def release_asset(asset_url, = {}) get(asset_url, ) end |
#release_assets(release_url, options = {}) ⇒ Array<Sawyer::Resource>
List release assets
73 74 75 |
# File 'lib/octokit/client/releases.rb', line 73 def release_assets(release_url, = {}) paginate release(release_url).rels[:assets].href, end |
#release_for_tag(repo, tag_name, options = {}) ⇒ Sawyer::Resource
Get the release for a given tag
136 137 138 |
# File 'lib/octokit/client/releases.rb', line 136 def release_for_tag(repo, tag_name, = {}) get "#{Repository.path repo}/releases/tags/#{tag_name}", end |
#releases(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_releases
List releases for a repository
14 15 16 |
# File 'lib/octokit/client/releases.rb', line 14 def releases(repo, = {}) paginate "#{Repository.path repo}/releases", end |
#update_release(url, options = {}) ⇒ Sawyer::Resource Also known as: edit_release
Update a release
54 55 56 |
# File 'lib/octokit/client/releases.rb', line 54 def update_release(url, = {}) patch url, end |
#update_release_asset(asset_url, options = {}) ⇒ Sawyer::Resource Also known as: edit_release_asset
Update a release asset
116 117 118 |
# File 'lib/octokit/client/releases.rb', line 116 def update_release_asset(asset_url, = {}) patch(asset_url, ) end |
#upload_asset(release_url, path_or_file, options = {}) ⇒ Sawyer::Resource
Upload a release asset
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/octokit/client/releases.rb', line 85 def upload_asset(release_url, path_or_file, = {}) file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, "rb") [:content_type] ||= content_type_from_file(file) raise Octokit::MissingContentType.new if [:content_type].nil? unless name = [:name] name = File.basename(file.path) end upload_url = release(release_url).rels[:upload].href_template.(:name => name) request :post, upload_url, file.read, parse_query_and_convenience_headers() ensure file.close if file end |