Class: Github::Issues
Defined Under Namespace
Classes: Assignees, Comments, Events, Labels, Milestones
Constant Summary collapse
- VALID_ISSUE_PARAM_NAMES =
%w[ assignee body creator direction filter labels milestone mentioned mime_type org resource since sort state title ].freeze
- VALID_ISSUE_PARAM_VALUES =
{ 'filter' => %w[ assigned created mentioned subscribed all ], 'state' => %w[ open closed ], 'sort' => %w[ created updated comments ], 'direction' => %w[ desc asc ], 'since' => %r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z} }
Constants included from Request
Request::METHODS, 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
-
#assignees(options = {}, &block) ⇒ Object
Access to Issues::Assignees API.
-
#comments(options = {}, &block) ⇒ Object
Access to Issues::Comments API.
-
#create(*args) ⇒ Object
Create an issue.
-
#edit(*args) ⇒ Object
Edit an issue.
-
#events(options = {}, &block) ⇒ Object
Access to Issues::Events API.
-
#get(*args) ⇒ Object
(also: #find)
Get a single issue.
-
#labels(options = {}, &block) ⇒ Object
Access to Issues::Comments API.
-
#list(*args) ⇒ Object
(also: #all)
List your issues.
-
#milestones(options = {}, &block) ⇒ Object
Access to Issues::Comments API.
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 RateLimit
#ratelimit, #ratelimit_remaining
Methods included from 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
#assignees(options = {}, &block) ⇒ Object
Access to Issues::Assignees API
40 41 42 |
# File 'lib/github_api/issues.rb', line 40 def assignees(={}, &block) @assignees ||= ApiFactory.new('Issues::Assignees', .merge(), &block) end |
#comments(options = {}, &block) ⇒ Object
Access to Issues::Comments API
45 46 47 |
# File 'lib/github_api/issues.rb', line 45 def comments(={}, &block) @comments ||= ApiFactory.new('Issues::Comments', .merge(), &block) end |
#create(*args) ⇒ Object
Create an issue
Inputs
<tt>:title</tt> - Required string
<tt>:body</tt> - Optional string
<tt>:assignee</tt> - Optional string - Login for the user that this issue should be assigned to.
Only users with push access can set the assignee for new issues.
The assignee is silently dropped otherwise.
<tt>:milestone</tt> - Optional number - Milestone to associate this issue with.
Only users with push access can set the milestone for new issues.
The milestone is silently dropped otherwise.
<tt>:labels</tt> - Optional array of strings - Labels to associate with this issue
Only users with push access can set labels for new issues.
Labels are silently dropped otherwise.
Examples
github = Github.new :user => 'user-name', :repo => 'repo-name'
github.issues.create
"title" => "Found a bug",
"body" => "I'm having a problem with this.",
"assignee" => "octocat",
"milestone" => 1,
"labels" => [
"Label1",
"Label2"
]
197 198 199 200 201 202 203 204 |
# File 'lib/github_api/issues.rb', line 197 def create(*args) arguments(args, :required => [:user, :repo]) do sift VALID_ISSUE_PARAM_NAMES assert_required %w[ title ] end post_request("/repos/#{user}/#{repo}/issues", arguments.params) end |
#edit(*args) ⇒ Object
Edit an issue
Inputs
<tt>:title</tt> - Optional string
<tt>:body</tt> - Optional string
<tt>:assignee</tt> - Optional string - Login for the user that this issue should be assigned to.
<tt>:state</tt> - Optional string - State of the issue:<tt>open</tt> or <tt>closed</tt>
<tt>:milestone</tt> - Optional number - Milestone to associate this issue with
<tt>:labels</tt> - Optional array of strings - Labels to associate with this issue. Pass one or more Labels to replace the set of Labels on this Issue. Send an empty array ([]) to clear all Labels from the Issue.
Examples
github = Github.new
github.issues.edit 'user-name', 'repo-name', 'number'
"title" => "Found a bug",
"body" => "I'm having a problem with this.",
"assignee" => "octocat",
"milestone" => 1,
"labels" => [
"Label1",
"Label2"
]
228 229 230 231 232 233 234 235 |
# File 'lib/github_api/issues.rb', line 228 def edit(*args) arguments(args, :required => [:user, :repo, :number]) do sift VALID_ISSUE_PARAM_NAMES end params = arguments.params patch_request("/repos/#{user}/#{repo}/issues/#{number}", params) end |
#events(options = {}, &block) ⇒ Object
Access to Issues::Events API
50 51 52 |
# File 'lib/github_api/issues.rb', line 50 def events(={}, &block) @events ||= ApiFactory.new('Issues::Events', .merge(), &block) end |
#get(*args) ⇒ Object Also known as: find
164 165 166 167 168 |
# File 'lib/github_api/issues.rb', line 164 def get(*args) arguments(args, :required => [:user, :repo, :number]) get_request("/repos/#{user}/#{repo}/issues/#{number}", arguments.params) end |
#labels(options = {}, &block) ⇒ Object
Access to Issues::Comments API
55 56 57 |
# File 'lib/github_api/issues.rb', line 55 def labels(={}, &block) @labels ||= ApiFactory.new('Issues::Labels', .merge(), &block) end |
#list(*args) ⇒ Object Also known as: all
List your issues
List all issues across all the authenticated user’s visible repositories including owned repositories, member repositories, and organization repositories.
Example
github = Github.new :oauth_token => '...'
github.issues.list
List all issues across owned and member repositories for the authenticated user.
Example
github = Github.new :oauth_token => '...'
github.issues.list :user
List all issues for a given organization for the authenticated user.
Example
github = Github.new :oauth_token => '...'
github.issues.list :org => 'org-name'
List issues for a repository
Example
github = Github.new
github.issues.list :user => 'user-name', :repo => 'repo-name'
Parameters
:filter
* <tt>assigned</tt> Issues assigned to you (default)
* <tt>created</tt> Issues created by you
* <tt>mentioned</tt> Issues mentioning you
* <tt>subscribed</tt> Issues you've subscribed to updates for
* <tt>all</tt> All issues the user can see
:milestone
* Integer Milestone number
* <tt>none</tt> for Issues with no Milestone.
* <tt>*</tt> for Issues with any Milestone
:state
- open
, closed
, default: open
:labels
- String list of comma separated Label names.
Example: bug,ui,@high
:assignee
* String User login
* <tt>none</tt> for Issues with no assigned User.
* <tt>*</tt> for Issues with any assigned User.
:creator
String User login :mentioned
String User login :sort
- created
, updated
, comments
,
default: <tt>created</tt>
:direction
- asc
, desc
, default: desc
:since
- Optional string of a timestamp in ISO 8601
format: YYYY-MM-DDTHH:MM:SSZ
Examples
github = Github.new :oauth_token => '...'
github.issues.list :since => '2011-04-12T12:12:12Z',
:filter => 'created',
:state => 'open',
:labels => "bug,ui,bla",
:sort => 'comments',
:direction => 'asc'
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/github_api/issues.rb', line 128 def list(*args) params = arguments(args) do assert_values VALID_ISSUE_PARAM_VALUES end.params response = if (org = params.delete('org')) get_request("/orgs/#{org}/issues", params) elsif (user_name = params.delete('user')) && (repo_name = params.delete('repo')) list_repo user_name, repo_name elsif args.include? :user get_request("/user/issues", params) else get_request("/issues", params) end return response unless block_given? response.each { |el| yield el } end |
#milestones(options = {}, &block) ⇒ Object
Access to Issues::Comments API
60 61 62 |
# File 'lib/github_api/issues.rb', line 60 def milestones(={}, &block) @milestones ||= ApiFactory.new('Issues::Milestones', .merge(), &block) end |