Created
October 2, 2014 19:26
-
-
Save ohadlevy/a6d5f8c5dadb318e129a to your computer and use it in GitHub Desktop.
pull request stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'octokit' | |
class PullRequestStat | |
attr_reader :project | |
Octokit.auto_paginate = true | |
def initialize project | |
@project = project | |
end | |
def pull_requests | |
issues.size | |
end | |
def labels | |
labels = {} | |
issues.each do |issue| | |
issue.labels.map(&:name).each do |label| | |
labels[label] ||= 0 | |
labels[label] += 1 | |
end | |
end | |
labels | |
end | |
private | |
def issues | |
@issues ||= client.issues(project) | |
end | |
def client | |
@client ||= Octokit::Client.new :access_token => 'TOKEN' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment