Sunday, April 19, 2009

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:
use Net::GitHub;
my $g2 = Net::GitHub->new( version => 2 ); # use Net::GitHub::V2
my $g2 = Net::GitHub->new( version => 1 ); # use Net::GitHub::V1

after 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: ,

Sunday, March 08, 2009

Net::GitHub

I just released the new http://search.cpan.org/dist/Net-GitHub/.

it's basically a Perl interface to github.com which is the most popular git host in the world. perl5's source and perl6's rakudo source are there too.

I'm starting to like git and I put my code there too.
be inspired by Net::Google::Code, I created the http://github.com/fayland/perl-net-github/tree/master
everyone is welcome to fork it then pull request back to me.

Thanks very much, Enjoy.

Labels: , ,