The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Github::Score - Pull author contribution counts for github repos

VERSION

version 0.2.0

AUTHOR

justin.d.hunter@gmail.com

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by AHB.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

NAME

Github::Score - Collect contributions data from the Github api.

SYNOPSIS

use Github::Score;

my $gs1 = Github::Score->new(); ##Bare constructor. Not much use without:
$gs1->user('Getty'); ## Still need a:
$gs1->repo('p5-www-duckduckgo');

my $contributors_scores = $gs1->scores();
## Do stuff with an array of this sort of thing:
#$VAR1 = [
#          {
#            'login' => 'doy',
#            'contributions' => 119
#          },
#          {
#            'login' => 'stevan',
#            'contributions' => 36
#          },
#          {
#            'login' => 'jasonmay',
#            'contributions' => 5
#          },
#          {
#            'login' => 'arcanez',
#            'contributions' => 3
#          }
#        ];

## Save yourself a few key-strokes
my $gs2 = Github::Score->new(user=>'Getty', repo=>'p5-www-duckduckgo'); 
$contributors_scores = $gs2->scores();

## Save yourself a few more key-strokes
my $gs3 = Github::Score->new('Getty/p5-www-duckduckgo'); 
$contributors_scores = $gs3->scores();

## Can't afford to wait for up to 10 seconds?
$gs3->timeout(9.99);
$contributors_scores = $gs3->scores();

DESCRIPTION

http://github-high-scores.heroku.com/ is a site with a retro-80s look and 
feel where you can look up the author contribution counts for projecs on Github.
Github::Score is an OO perl API to the same data from the site aimed at the 
DuckDuckGo community platform. 

METHODS

Constructors

new

Github::Score objects can be constructed in different ways:
Empty constructor call

new()

Single url-style string

new('contributor/github-repo')

Key-value pairs

new(user=>someone, repo=>'some-repo', timeout=> $_10_if_you_leave_it_out)

Hash reference

new( {user=>someone, repo=>'some-repo', timeout=> $_10_if_you_leave_it_out)}

Accessors

user

Will set $self->{user} to $_[0], if an argument is given.
Returns: $self->{user}

repo

Will set $self-{repo}  to $_[0], if an argument is given.
Returns: $self-{repo} 

timeout

Will set $self->{timeout} to $_[0], if an argument is given.
Returns: $self->{timeout}

Note: Defaults to 10 when the object is constructed.

ua

Returns: A LWP::UserAgent instance

Note: Do not use this method directly. It is automatically invoked by the
scores method.

uri

Returns: A URI instance

Note: Do not use this method directly. It is automatically invoked by the
scores method.

json

Returns: A JSON instance

Note: Do not use this method directly. It is automatically invoked by the
scores method.

Behaviour

scores

Returns: A reference to a hash of login/contribution pairs.

Note: The hash could be empty if there is some error with the request,
or example a timeout, or if the query is invalid, for example user
does not contribute to the repository.

BUGS

None known, but they will be there somewhere.

TODO

Github api v3 support
Support regex user/repo queries
Retry on timeout?
Better documentation.

SEE ALSO

http://github-high-scores.heroku.com/
Net::GitHub
http://github.com
App::DuckDuckGo
WWW::DuckDuckGo
http://duck.co/