Class: Lita::Handlers::GithubRepo
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::GithubRepo
- Includes:
- LitaGithub::Config, LitaGithub::Filters, LitaGithub::General, 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_rename(response) ⇒ Object
- #repo_team_router(response) ⇒ Object
- #repo_teams_list(response) ⇒ Object
- #repo_update_router(response) ⇒ Object
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
#repo_create(response) ⇒ Object
rubocop:enable Metrics/LineLength
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/lita/handlers/github_repo.rb', line 117 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(opts_parse(response..body), org) response.reply(create_repo(org, repo, opts)) end |
#repo_delete(response) ⇒ Object
141 142 143 144 145 146 147 148 149 |
# File 'lib/lita/handlers/github_repo.rb', line 141 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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/lita/handlers/github_repo.rb', line 151 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_rename(response) ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'lib/lita/handlers/github_repo.rb', line 131 def repo_rename(response) return response.reply(t('method_disabled')) if func_disabled?(__method__) org, repo = repo_match(response.match_data) new_repo = response.match_data['repo_name'] return response.reply(t('not_found', org: org, repo: repo)) unless repo?(rpo(org, repo)) response.reply(rename_repo(org, repo, new_repo)) end |
#repo_team_router(response) ⇒ Object
190 191 192 193 |
# File 'lib/lita/handlers/github_repo.rb', line 190 def repo_team_router(response) action = response.match_data['action'].strip response.reply(send("repo_team_#{action}".to_sym, response)) end |
#repo_teams_list(response) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/lita/handlers/github_repo.rb', line 169 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 |
#repo_update_router(response) ⇒ Object
195 196 197 198 |
# File 'lib/lita/handlers/github_repo.rb', line 195 def repo_update_router(response) field = response.match_data['field'].strip response.reply(send("repo_update_#{field}".to_sym, response)) end |