Net::GitHub 0.06
github just released its V2 API version days ago, I spent some hours to update the Net::GitHub.
it's really not a fun to both support V1 and V2 on the same time, I mean some code like follows:
after a nice sleep, I come out a solution like:
maybe there is a better way, but it works at least for now.
Thanks and enjoy.
it's really not a fun to both support V1 and V2 on the same time, I mean some code like follows:
use Net::GitHub;
my $g2 = Net::GitHub->new( version => 2 ); # use Net::GitHub::V2
my $g2 = Net::GitHub->new( version => 1 ); # use Net::GitHub::V1after a nice sleep, I come out a solution like:
package Net::GitHub;
use Moose;
our $VERSION = '0.06';
our $AUTHORITY = 'cpan:FAYLAND';
sub new {
my $class = shift;
my $params = $class->BUILDARGS(@_);
my $obj;
if ( $params->{version} == 1 ) {
require Net::GitHub::V1;
$obj = Net::GitHub::V1->new($params);
} else {
require Net::GitHub::V2;
$obj = Net::GitHub::V2->new($params);
}
return $class->meta->new_object(
__INSTANCE__ => $obj,
@_,
);
}
no Moose;
__PACKAGE__->meta->make_immutable;
1;maybe there is a better way, but it works at least for now.
Thanks and enjoy.
Labels: github, Net-GitHub
