Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
Created June 1, 2013 19:57
Show Gist options
  • Save ryanbriones/5691547 to your computer and use it in GitHub Desktop.
Save ryanbriones/5691547 to your computer and use it in GitHub Desktop.
Civic Needs Issue test
require "sinatra"
require "octokit"
class CivicNeedsIssuesList < Sinatra::Base
get "/" do
out = ""
Octokit.list_issues("ryanbriones/civicneeds", {:labels => "need"}).each do |issue|
out << %Q{<a href="/needs/#{issue.number}">##{issue.number} #{issue.title} (#{issue.comments} comments)</a>}
end
out
end
get "/needs/:issue_id" do |issue_id|
out = ""
issue = Octokit.issue("ryanbriones/civicneeds", issue_id)
issue_is_need = if issue
is_need = false
issue.labels.each do |label|
if label.name == "need"
is_need = true
break
end
end
is_need
else
false
end
if issue && issue_is_need
out << "<h1>#{issue.title}</h1>"
out << "<p>#{issue.body}</p>"
out << "<h2>Comments</h2>"
Octokit.issue_comments("ryanbriones/civicneeds", issue_id).each do |comment|
out << "<p><b>#{comment.user.login}</b> #{comment.body}</p>"
end
out
else
out = "Could not find need"
end
end
end
run CivicNeedsIssuesList.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment