Class: Lita::Handlers::GithubIssues
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::GithubIssues
- Includes:
- LitaGithub::Config, LitaGithub::Filters, LitaGithub::General, LitaGithub::Octo, LitaGithub::Org, LitaGithub::Repo
- Defined in:
- lib/lita/handlers/github_issues.rb
Overview
GitHub Issues Lita Handler
Constant Summary collapse
- LI_STATES =
issue states
%w(open closed all)
- LI_SM =
issue states
%w(created updated comments)
- LI_DIR =
sort direction
%w(asc desc)
Constants included from LitaGithub::Repo
LitaGithub::Repo::PR_LIST_MAX_COUNT
Instance Method Summary collapse
-
#issues_list(response) ⇒ Object
This is the handler for listing issues on a repository.
Methods included from LitaGithub::Filters
Methods included from LitaGithub::Repo
#repo?, #repo_has_team?, #repo_match, #rpo
Methods included from LitaGithub::Org
#organization, #sort_by_name, #team?, #team_id, #team_id_by_slug
Methods included from LitaGithub::Octo
#access_token, #octo, #setup_octo
Methods included from LitaGithub::Config
Methods included from LitaGithub::General
#opts_parse, #symbolize_opt_key, #to_i_if_numeric
Instance Method Details
#issues_list(response) ⇒ Object
This is the handler for listing issues on a repository
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/lita/handlers/github_issues.rb', line 58 def issues_list(response) full_name = rpo(*repo_match(response.match_data)) opts = opts_parse(response..body) oops = validate_list_opts(opts) return response.reply(oops) unless oops.empty? return response.reply(t('repo_not_found', repo: full_name)) unless repo?(full_name) # get the issues that are not pull requests begin issues = octo.list_issues(full_name, opts).reject { |i| i.key?(:pull_request) } rescue Octokit::UnprocessableEntity => e return response.reply(t('issues_list.invalid_opts', m: e.)) rescue StandardError => e return response.reply(t('boom', m: e.)) end if issues.empty? reply = t('issues_list.none', r: full_name) else reply = t('issues_list.header', n: issues.length, r: full_name) issues.each { |i| reply << t('issues_list.item', i.to_h.merge(u: i[:user][:login], r: full_name)) } end response.reply(reply) end |