Created
March 10, 2011 14:21
-
-
Save schwern/864149 to your computer and use it in GitHub Desktop.
Get the number of issues from a github project
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
| use Net::GitHub::V2::Issues; | |
| use URI; | |
| # Examples: | |
| # http://github.com/schwern/test-more/tree/master | |
| # http://github.com/sukria/Dancer | |
| sub num_github_issues { | |
| my $url = URI->new(shift); | |
| return unless $url->host =~ m{\.?github.com$}; | |
| my $path = $url->path; | |
| my($owner, $repo) = grep { length $_ } split m{/}, $path; | |
| return unless $owner && $repo; | |
| my $issues = Net::GitHub::V2::Issues->new( | |
| owner => $owner, repo => $repo | |
| ); | |
| return unless $issues; | |
| my $open_issues = $issues->list("open"); | |
| return unless ref $open_issues eq 'ARRAY'; | |
| return scalar @$open_issues; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment