Class: Github::Repos::Releases
- Defined in:
- lib/github_api/repos/releases.rb
Overview
The Releases API
Defined Under Namespace
Classes: Assets
Constant Summary collapse
- VALID_RELEASE_PARAM_NAMES =
%w[ tag_name target_commitish name body draft prerelease ].freeze
Constants included from Github::Request
Github::Request::METHODS, Github::Request::METHODS_WITH_BODIES
Constants included from Connection
Constants included from Constants
Constants::ACCEPT, Constants::ACCEPTED_OAUTH_SCOPES, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::OAUTH_SCOPES, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT
Constants included from MimeType
Instance Attribute Summary
Attributes inherited from API
Attributes included from Authorization
Instance Method Summary collapse
-
#assets(options = {}, &block) ⇒ Object
Access to Repos::Releases::Assets API.
-
#create(*args) ⇒ Object
Create a release.
-
#delete(*args) ⇒ Object
Delete a release.
-
#edit(*args) ⇒ Object
(also: #update)
Edit a release.
-
#get(*args) ⇒ Object
(also: #find)
Get a single release.
-
#list(*args) ⇒ Object
(also: #all)
List releases for a repository.
Methods inherited from API
#api_methods_in, #append_arguments, #arguments, inherited, #initialize, #method_missing, #process_basic_auth, #set, #setup, #with, #yield_or_eval
Methods included from Github::RateLimit
#ratelimit, #ratelimit_remaining
Methods included from Github::Request
#delete_request, #get_request, #patch_request, #post_request, #put_request, #request
Methods included from Connection
#caching?, #clear_cache, #connection, #default_middleware, #default_options, #stack
Methods included from MimeType
Methods included from Authorization
#auth_code, #authenticated?, #authentication, #authorize_url, #basic_authed?, #client, #get_token
Constructor Details
This class inherits a constructor from Github::API
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Github::API
Instance Method Details
#assets(options = {}, &block) ⇒ Object
Access to Repos::Releases::Assets API
20 21 22 |
# File 'lib/github_api/repos/releases.rb', line 20 def assets( = {}, &block) @assets ||= ApiFactory.new('Repos::Releases::Assets', .merge(), &block) end |
#create(*args) ⇒ Object
Create a release
Inputs
-
:tag_name
- Required string -
:target_commitish
- Optional string - Specifies the commitishvalue that determines where the Git tag is created from. Can be any branch or commit SHA. Defaults to the repository's default branch (usually 'master'). Unused if the Git tag already exists.
-
:name
- Optional string -
:body
- Optional string -
:draft
- Optional boolean -true
to create a draft(unpublished) release, <tt>false</tt> to create a published one. Default is false.
-
:prerelease
- Optional boolean -true
to identifythe release as a prerelease. false to identify the release as a full release. Default is false.
Examples
github = Github.new
github.repos.releases.create 'owner', 'repo', 'tag-name',
"tag_name": "v1.0.0",
"target_commitish": "master",
"name": "v1.0.0",
"body": "Description of the release",
"draft": false,
"prerelease": false
82 83 84 85 86 87 88 89 90 |
# File 'lib/github_api/repos/releases.rb', line 82 def create(*args) arguments(args, required: [:owner, :repo, :tag_name]) do sift VALID_RELEASE_PARAM_NAMES end params = arguments.params params['tag_name'] = tag_name post_request("/repos/#{owner}/#{repo}/releases", params) end |
#delete(*args) ⇒ Object
137 138 139 140 141 |
# File 'lib/github_api/repos/releases.rb', line 137 def delete(*args) params = arguments(args, required: [:owner, :repo, :id]).params delete_request("/repos/#{owner}/#{repo}/releases/#{id}", params) end |
#edit(*args) ⇒ Object Also known as: update
Edit a release
Inputs
-
:tag_name
- Required string -
:target_commitish
- Optional string - Specifies the commitishvalue that determines where the Git tag is created from. Can be any branch or commit SHA. Defaults to the repository's default branch (usually 'master'). Unused if the Git tag already exists.
-
:name
- Optional string -
:body
- Optional string -
:draft
- Optional boolean -true
to create a draft(unpublished) release, <tt>false</tt> to create a published one. Default is false.
-
:prerelease
- Optional boolean -true
to identifythe release as a prerelease. false to identify the release as a full release. Default is false.
Examples
github = Github.new
github.repos.releases.edit 'owner', 'repo', 'id',
"tag_name": "v1.0.0",
"target_commitish": "master",
"name": "v1.0.0",
"body": "Description of the release",
"draft": false,
"prerelease": false
119 120 121 122 123 124 125 126 |
# File 'lib/github_api/repos/releases.rb', line 119 def edit(*args) arguments(args, required: [:owner, :repo, :id]) do sift VALID_RELEASE_PARAM_NAMES end params = arguments.params patch_request("/repos/#{owner}/#{repo}/releases/#{id}", params) end |
#get(*args) ⇒ Object Also known as: find
49 50 51 52 |
# File 'lib/github_api/repos/releases.rb', line 49 def get(*args) params = arguments(args, required: [:owner, :repo, :id]).params get_request("/repos/#{owner}/#{repo}/releases/#{id}" , params) end |
#list(*args) ⇒ Object Also known as: all
List releases for a repository
Users with push access to the repository will receive all releases (i.e., published releases and draft releases). Users with pull access will receive published releases only.
Examples
github = Github.new
github.repos.releases.list 'owner', 'repo'
github.repos.releases.list 'owner', 'repo' { |release| ... }
35 36 37 38 39 40 |
# File 'lib/github_api/repos/releases.rb', line 35 def list(*args) params = arguments(args, required: [:owner, :repo]).params response = get_request("/repos/#{owner}/#{repo}/releases", params) return response unless block_given? response.each { |el| yield el } end |