Module: Octokit::Client::Releases
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/octokit/client/releases.rb |
Overview
Methods for the Releases
API
Instance Method Summary
-
#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.
-
#edit_release(url, options = {})
Alias for #update_release.
-
#edit_release_asset(asset_url, options = {})
Alias for #update_release_asset.
-
#latest_release(repo, options = {}) ⇒ Sawyer::Resource
Get the latest release.
-
#list_releases(repo, options = {})
Alias for #releases.
-
#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.
- #content_type_from_file(file) private
Instance Method Details
#content_type_from_file(file) (private)
[ GitHub ]# File 'lib/octokit/client/releases.rb', line 153
def content_type_from_file(file) require 'mime/types' if mime_type = MIME::Types.type_for(file.path).first mime_type.content_type end rescue LoadError msg = 'Please pass content_type or install mime-types gem to guess content type from file' raise Octokit::MissingContentType, msg end
#create_release(repo, tag_name, options = {}) ⇒ Sawyer::Resource
Create a release
# 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
# File 'lib/octokit/client/releases.rb', line 65
def delete_release(url, = {}) boolean_from_response(:delete, url, ) end
#delete_release_asset(asset_url, options = {}) ⇒ Boolean
Delete a release asset
# File 'lib/octokit/client/releases.rb', line 128
def delete_release_asset(asset_url, = {}) boolean_from_response(:delete, asset_url, ) end
#edit_release(url, options = {})
Alias for #update_release.
# File 'lib/octokit/client/releases.rb', line 58
alias edit_release update_release
#edit_release_asset(asset_url, options = {})
Alias for #update_release_asset.
# File 'lib/octokit/client/releases.rb', line 121
alias edit_release_asset update_release_asset
#latest_release(repo, options = {}) ⇒ Sawyer::Resource
Get the latest release
# File 'lib/octokit/client/releases.rb', line 147
def latest_release(repo, = {}) get "#{Repository.path repo}/releases/latest", end
#list_releases(repo, options = {})
Alias for #releases.
# File 'lib/octokit/client/releases.rb', line 17
alias list_releases releases
#release(url, options = {}) ⇒ Sawyer::Resource
Get a release
# 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
# File 'lib/octokit/client/releases.rb', line 107
def release_asset(asset_url, = {}) get(asset_url, ) end
#release_assets(release_url, options = {}) ⇒ Array
<Sawyer::Resource
>
List release assets
# File 'lib/octokit/client/releases.rb', line 74
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
# File 'lib/octokit/client/releases.rb', line 138
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
# 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
# File 'lib/octokit/client/releases.rb', line 55
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
# File 'lib/octokit/client/releases.rb', line 118
def update_release_asset(asset_url, = {}) patch(asset_url, ) end
#upload_asset(release_url, path_or_file, options = {}) ⇒ Sawyer::Resource
Upload a release asset
# File 'lib/octokit/client/releases.rb', line 86
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 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 end