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
65 66 67 |
# 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
127 128 129 |
# File 'lib/octokit/client/releases.rb', line 127 def delete_release_asset(asset_url, = {}) boolean_from_response(:delete, asset_url, ) end |
#latest_release(repo, options = {}) ⇒ Sawyer::Resource
Get the latest release
146 147 148 |
# File 'lib/octokit/client/releases.rb', line 146 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
106 107 108 |
# File 'lib/octokit/client/releases.rb', line 106 def release_asset(asset_url, = {}) get(asset_url, ) end |
#release_assets(release_url, options = {}) ⇒ Array<Sawyer::Resource>
List release assets
74 75 76 |
# 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
137 138 139 |
# File 'lib/octokit/client/releases.rb', line 137 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
55 56 57 |
# 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
117 118 119 |
# File 'lib/octokit/client/releases.rb', line 117 def update_release_asset(asset_url, = {}) patch(asset_url, ) end |
#upload_asset(release_url, path_or_file, options = {}) ⇒ Sawyer::Resource
Upload a release asset
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# 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.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 |