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

update to Github API v3 with Net::GitHub #2

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 1 addition & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ WriteMakefile(
'PREREQ_PM' => {
Sysadm::Install => 0.37,
Log::Log4perl => 1.0,
LWP::UserAgent => 5,
XML::Simple => 2.18,
Net::Github => 0.50,
File::Temp => 0.22,
YAML => 0.71,
}, # e.g., Module::Name => 1.1
Expand Down
23 changes: 5 additions & 18 deletions lib/GitMeta/Github.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ package GitMeta::Github;
use strict;
use warnings;
use base qw(GitMeta);
use LWP::UserAgent;
use XML::Simple;
use Net::Github;

###########################################
sub expand {
Expand All @@ -19,24 +18,12 @@ sub expand {
my $user = $self->{user};
my @repos = ();

my $ua = LWP::UserAgent->new();
my $resp = $ua->get(
"http://github.com/api/v1/xml/$user");
my $gh = Net::GitHub::V3->new;
my @by_repos = $gh->repos->list_user($user);

if($resp->is_error) {
die "API fetch failed: ",
$resp->message();
}

my $xml = XMLin(
$resp->decoded_content());

my $by_repo =
$xml->{repositories}->{repository};

for my $repo (keys %$by_repo) {
for my $repo (@by_repos) {
push @repos,
"git\@github.com:$user/$repo.git";
$repo->{'ssh_url'};
}

return @repos;
Expand Down