Pithub::Repos::Contents - Github v3 Repo Contents API
version 0.01021
This method will return a 302 to a URL to download a tarball or zipball archive for a repository.
302
Note: For private repositories, these links are temporary and expire quickly.
GET /repos/:user/:repo/:archive_format/:ref
The ref parameter is optional and will default to master.
ref
master
Examples:
my $c = Pithub::Repos::Contents->new( repo => 'Pithub', user => 'plu' ); my $result = $c->archive( archive_format => 'tarball' ); if ( $result->success ) { File::Slurp::write_file('Pithub-master.tgz', $result->raw_content); } $result = $c->archive( archive_format => 'tarball', ref => 'other_branch' ); if ( $result->success ) { File::Slurp::write_file('Pithub-other_branch.tgz', $result->raw_content); }
This method returns the contents of any file or directory in a repository.
GET /repos/:user/:repo/contents/:path
Optional Parameters:
ref: Optional string - The String name of the Commit/Branch/Tag. Defaults to master.
my $c = Pithub::Repos::Contents->new( repo => 'Pithub', user => 'plu' ); # List all files/directories in the repo root my $result = $c->get; if ( $result->success ) { say $_->{name} for @{ $result->content }; } # Get the Pithub.pm file $result = $c->get( path => 'lib/Pithub.pm' ); print Dumper $result->content if $result->success;
This method returns the preferred README for a repository.
GET /repos/:user/:repo/readme
my $c = Pithub::Repos::Contents->new( repo => 'dotfiles', user => 'plu' ); my $result = $c->readme; if ( $result->success ) { print Dumper $result->content; } # Get the readme of branch 'other_branch' $result = $c->readme( params => { ref => 'other_branch' } ); print Dumper $result->content if $result->success;
Johannes Plunien <plu@cpan.org>
This software is copyright (c) 2011 by Johannes Plunien.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Pithub, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pithub
CPAN shell
perl -MCPAN -e shell install Pithub
For more information on module installation, please visit the detailed CPAN module installation guide.