Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix too match meta programming #50

Merged
merged 2 commits into from
Mar 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/github/nippou/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 0 additions & 9 deletions lib/github/nippou/concerns/sawyer_resource_github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down