diff --git a/lib/github/nippou/commands.rb b/lib/github/nippou/commands.rb index ba557c5..c8a1d3d 100644 --- a/lib/github/nippou/commands.rb +++ b/lib/github/nippou/commands.rb @@ -17,7 +17,7 @@ class Commands < Thor desc 'list', "Displays today's GitHub events formatted for Nippou" def list user_events.each do |user_event| - issue = user_event.issue(client) + issue = issue(user_event) line = "* [%s - %s](%s) by %s" % [issue.title.markdown_escape, user_event.repo.name, user_event.html_url, issue.user.login] if issue.merged @@ -42,6 +42,14 @@ def user_events ).collect end + def issue(user_event) + if user_event.issue? + client.issue(user_event.repo.name, user_event.payload.issue.number) + else + client.pull_request(user_event.repo.name, user_event.payload.pull_request.number) + end + end + def client @client ||= Octokit::Client.new(login: user, access_token: access_token) end diff --git a/lib/github/nippou/concerns/sawyer_resource_github.rb b/lib/github/nippou/concerns/sawyer_resource_github.rb index 7f5bcb3..2d39355 100644 --- a/lib/github/nippou/concerns/sawyer_resource_github.rb +++ b/lib/github/nippou/concerns/sawyer_resource_github.rb @@ -2,15 +2,6 @@ module SawyerResourceGithub refine Sawyer::Resource do - def issue(client) - case - when self.issue? - client.issue(self.repo.name, self.payload.issue.number) - when self.pull_request? - client.pull_request(self.repo.name, self.payload.pull_request.number) - end - end - def html_url case when self.issue?