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_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
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/lita/handlers/github_repo.rb', line 100 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
114 115 116 117 118 119 120 121 122 |
# File 'lib/lita/handlers/github_repo.rb', line 114 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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/lita/handlers/github_repo.rb', line 124 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
163 164 165 166 |
# File 'lib/lita/handlers/github_repo.rb', line 163 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
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/lita/handlers/github_repo.rb', line 142 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
168 169 170 171 |
# File 'lib/lita/handlers/github_repo.rb', line 168 def repo_update_router(response) field = response.match_data['field'].strip response.reply(send("repo_update_#{field}".to_sym, response)) end |