Class: Lita::Handlers::GithubRepo
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::GithubRepo
- Includes:
- LitaGithub::Config, LitaGithub::Filters, LitaGithub::Octo, LitaGithub::Org, LitaGithub::Repo
- Defined in:
- lib/lita/handlers/github_repo.rb
Overview
GitHub Lita Handler
Constant Summary
Constants included from LitaGithub::Repo
LitaGithub::Repo::PR_LIST_MAX_COUNT
Instance Method Summary collapse
-
#repo_create(response) ⇒ Object
rubocop:enable Metrics/LineLength.
- #repo_delete(response) ⇒ Object
- #repo_info(response) ⇒ Object
- #repo_team_router(response) ⇒ Object
- #repo_teams_list(response) ⇒ Object
Methods included from LitaGithub::Filters
Methods included from LitaGithub::Repo
#repo?, #repo_has_team?, #repo_match, #rpo
Methods included from LitaGithub::Org
Methods included from LitaGithub::Octo
#access_token, #octo, #setup_octo
Methods included from LitaGithub::Config
Instance Method Details
#repo_create(response) ⇒ Object
rubocop:enable Metrics/LineLength
89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/lita/handlers/github_repo.rb', line 89 def repo_create(response) return response.reply(t('method_disabled')) if func_disabled?(__method__) org, repo = repo_match(response.match_data) if repo?(rpo(org, repo)) return response.reply(t('repo_create.exists', org: org, repo: repo)) end opts = extrapolate_create_opts(command_opts(response.args.join(' ')), org) response.reply(create_repo(org, repo, opts)) end |
#repo_delete(response) ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/lita/handlers/github_repo.rb', line 103 def repo_delete(response) return response.reply(t('method_disabled')) if func_disabled?(__method__) org, repo = repo_match(response.match_data) return response.reply(t('not_found', org: org, repo: repo)) unless repo?(rpo(org, repo)) response.reply(delete_repo(org, repo)) end |
#repo_info(response) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/lita/handlers/github_repo.rb', line 113 def repo_info(response) org, repo = repo_match(response.match_data) full_name = rpo(org, repo) opts = {} r_obj = octo.repository(full_name) p_obj = octo.pull_requests(full_name) opts[:repo] = r_obj[:full_name] opts[:description] = r_obj[:description] opts[:private] = r_obj[:private] opts[:url] = r_obj[:html_url] opts[:raw_issues_count] = r_obj[:open_issues_count] opts[:pr_count] = p_obj.length opts[:issues_count] = opts[:raw_issues_count] - opts[:pr_count] response.reply(t('repo_info.reply', opts)) end |
#repo_team_router(response) ⇒ Object
152 153 154 155 |
# File 'lib/lita/handlers/github_repo.rb', line 152 def repo_team_router(response) action = response.match_data['action'] response.reply(send("repo_team_#{action}".to_sym, response)) end |
#repo_teams_list(response) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/lita/handlers/github_repo.rb', line 131 def repo_teams_list(response) org, repo = repo_match(response.match_data) full_name = rpo(org, repo) begin teams = octo.repository_teams(full_name) rescue Octokit::NotFound return response.reply(t('not_found', org: org, repo: repo)) end if teams.length == 0 reply = t('repo_team_list.none', org: org, repo: full_name) else reply = t('repo_team_list.header', num_teams: teams.length, repo: full_name) end sort_by_name(teams).each { |team| reply << t('repo_team_list.team', team.to_h) } response.reply(reply) end |