| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Pithub::Repos::Contents; | 
| 2 |  |  |  |  |  |  | our $AUTHORITY = 'cpan:PLU'; | 
| 3 |  |  |  |  |  |  | our $VERSION = '0.01041'; | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | # ABSTRACT: Github v3 Repo Contents API | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 16 |  |  | 16 |  | 142 | use Moo; | 
|  | 16 |  |  |  |  | 51 |  | 
|  | 16 |  |  |  |  | 93 |  | 
| 8 | 16 |  |  | 16 |  | 7750 | use Carp qw( croak ); | 
|  | 16 |  |  |  |  | 51 |  | 
|  | 16 |  |  |  |  | 7246 |  | 
| 9 |  |  |  |  |  |  | extends 'Pithub::Base'; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub archive { | 
| 13 | 5 |  |  | 5 | 1 | 10015 | my ( $self, %args ) = @_; | 
| 14 |  |  |  |  |  |  | croak 'Missing key in parameters: archive_format' | 
| 15 | 5 | 100 |  |  |  | 38 | unless $args{archive_format}; | 
| 16 |  |  |  |  |  |  | croak 'Invalid archive_format. Valid formats: tarball, zipball' | 
| 17 | 4 | 100 |  |  |  | 30 | unless grep $args{archive_format} eq $_, qw(tarball zipball); | 
| 18 | 3 |  |  |  |  | 27 | $self->_validate_user_repo_args( \%args ); | 
| 19 |  |  |  |  |  |  | return $self->request( | 
| 20 |  |  |  |  |  |  | method => 'GET', | 
| 21 |  |  |  |  |  |  | path   => sprintf( | 
| 22 |  |  |  |  |  |  | '/repos/%s/%s/%s/%s', delete $args{user}, delete $args{repo}, | 
| 23 | 3 |  | 100 |  |  | 48 | delete $args{archive_format}, delete $args{ref} || q{} | 
| 24 |  |  |  |  |  |  | ), | 
| 25 |  |  |  |  |  |  | %args, | 
| 26 |  |  |  |  |  |  | ); | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | sub get { | 
| 31 | 3 |  |  | 3 | 1 | 4061 | my ( $self, %args ) = @_; | 
| 32 | 3 |  |  |  |  | 22 | $self->_validate_user_repo_args( \%args ); | 
| 33 | 3 | 100 |  |  |  | 22 | if ( my $path = delete $args{path} ) { | 
| 34 |  |  |  |  |  |  | return $self->request( | 
| 35 |  |  |  |  |  |  | method => 'GET', | 
| 36 |  |  |  |  |  |  | path   => sprintf( | 
| 37 |  |  |  |  |  |  | '/repos/%s/%s/contents/%s', delete $args{user}, | 
| 38 | 1 |  |  |  |  | 14 | delete $args{repo},         $path | 
| 39 |  |  |  |  |  |  | ), | 
| 40 |  |  |  |  |  |  | %args, | 
| 41 |  |  |  |  |  |  | ); | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | return $self->request( | 
| 44 |  |  |  |  |  |  | method => 'GET', | 
| 45 |  |  |  |  |  |  | path   => sprintf( | 
| 46 |  |  |  |  |  |  | '/repos/%s/%s/contents', delete $args{user}, delete $args{repo} | 
| 47 | 2 |  |  |  |  | 25 | ), | 
| 48 |  |  |  |  |  |  | %args, | 
| 49 |  |  |  |  |  |  | ); | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub readme { | 
| 54 | 2 |  |  | 2 | 1 | 1611 | my ( $self, %args ) = @_; | 
| 55 | 2 |  |  |  |  | 15 | $self->_validate_user_repo_args( \%args ); | 
| 56 |  |  |  |  |  |  | return $self->request( | 
| 57 |  |  |  |  |  |  | method => 'GET', | 
| 58 |  |  |  |  |  |  | path   => sprintf( | 
| 59 |  |  |  |  |  |  | '/repos/%s/%s/readme', delete $args{user}, delete $args{repo} | 
| 60 | 2 |  |  |  |  | 43 | ), | 
| 61 |  |  |  |  |  |  | %args, | 
| 62 |  |  |  |  |  |  | ); | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | 1; | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | __END__ |