Skip to content

Commit

Permalink
Add the API for .gitignore templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Lequertier committed Jan 30, 2016
1 parent dc77a22 commit a910fa2
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Net/GitHub/V3.pm
Expand Up @@ -17,6 +17,7 @@ use Net::GitHub::V3::GitData;
use Net::GitHub::V3::Gists;
use Net::GitHub::V3::OAuth;
use Net::GitHub::V3::Events;
use Net::GitHub::V3::Gitignore;
use Net::GitHub::V3::Search;

has '+is_main_module' => (default => 1);
Expand Down Expand Up @@ -125,6 +126,16 @@ has 'search' => (
},
);

has 'gitignore' => (
is => 'rw',
isa => InstanceOf['Net::GitHub::V3::Gitignore'],
lazy => 1,
default => sub {
my $self = shift;
return Net::GitHub::V3::Gitignore->new( $self->args_to_pass );
},
);

no Moo;

1;
Expand Down
76 changes: 76 additions & 0 deletions lib/Net/GitHub/V3/Gitignore.pm
@@ -0,0 +1,76 @@
package Net::GitHub::V3::Gitignore;

use Moo;

our $VERSION = '0.60';
our $AUTHORITY = 'cpan:FAYLAND';

use URI::Escape;

with 'Net::GitHub::V3::Query';

sub templates {
my ( $self, $args ) = @_;

# for old
unless (ref($args) eq 'HASH') {
$args = { type => $args };
}

my $uri = URI->new('/gitignore/templates');
$uri->query_form($args);
return $self->query($uri->as_string);
}

sub template {
my ( $self, $template, $args ) = @_;

# for old
unless (ref($args) eq 'HASH') {
$args = { type => $args };
}
print $args;
my $uri = URI->new("/gitignore/templates/" . uri_escape($template));
$uri->query_form($args);
return $self->query($uri->as_string);
}

no Moo;

1;
__END__
=head1 NAME
Net::GitHub::V3::Gitignore - GitHub Gitignore API
=head1 SYNOPSIS
use Net::GitHub::V3;
my $gh = Net::GitHub::V3->new; # read L<Net::GitHub::V3> to set right authentication info
my $gitignore = $gh->gitignore;
=head1 DESCRIPTION
=head2 METHODS
=head3 Gitignore
L<http://developer.github.com/v3/gitignore/>
=over 4
=item templates
my @templates = $gitignore->templates();
=item template
my template = $gitignore->template('Perl');
=back
=head1 AUTHOR & COPYRIGHT & LICENSE
Refer L<Net::GitHub>

0 comments on commit a910fa2

Please sign in to comment.