NAME
WWW::GitHub::Gist::v3 - Perl interface to GitHub's Gist pastebin service (v3)
VERSION
version 0.12
SYNOPSIS
use feature 'say';
use WWW::GitHub::Gist::v3;
my $gist = WWW::GitHub::Gist::v3 -> new(
id => '1216637',
#user => $username,
#password => $password
);
# Fetch and print information
my $gist_info = $gist -> show;
say $gist_info -> {'description'};
say $gist_info -> {'user'} -> {'login'};
say $gist_info -> {'git_pull_url'};
say $gist_info -> {'git_push_url'};
# Show files
my $files = $gist_info -> {'files'};
foreach my $file (keys %$files) {
say $files -> {$file} -> {'filename'};
say $files -> {$file} -> {'content'};
}
# Create a new gist
my $new_gist_info = $gist -> create(
description => $descr,
public => 1,
files => {'name1' => 'content', 'name2' => 'content'}
);
DESCRIPTION
WWW::GitHub::Gist is an object-oriented interface to the pastebin service of GitHub gist.github.com.
This is the interface to the version 3 of the API.
METHODS
new( )
Create a new WWW::GitHub::Gist object. Takes the following arguments:
id
Gist id.
user
Username
password
Authenticating user's password.
The username and password are used for the methods that require auth. The username is also used in the list()
method.
show( $gist_id )
Fetch information of the given gist. By default uses the 'id' attribute defined in ->new.
Returns an hash ref containing the gist's information.
list( $user )
List all gists of the given user. By default uses the 'user' attribute defined in ->new.
Returns a list of hash refs containing the gists' information.
create( %args )
Create a new gist. Takes the following arguments:
description
The description for the new gist (optional).
public
Whether the new gist is public or not (optional, defaults to '1').
files
A hash reference containing the new gist's file names and conttents.
Returns an hash ref containing the new gist's information.
(requires authentication)
edit( %args )
Updates a gist. Takes the following arguments:
id
The id of the gist to be updated. By default uses the 'id' attribute defined in ->new.
description
The updated description for the gist (optional).
public
Whether the new gist is public or not (optional, defaults to '1').
files
A hash reference containing the gist's updated file names and conttents.
Returns an hash ref containing the updated gist's information.
(requires authentication)
fork($gist_id)
Forks the given gist. By default uses the 'id' attribute defined in ->new.
Returns an hash ref containing the forked gist's information.
(requires authentication)
delete($gist_id)
Deletes the given gist. By default uses the 'id' attribute defined in ->new.
Returns nothing.
(requires authentication)
star($gist_id)
Stars the given gist. By default uses the 'id' attribute defined in ->new.
Returns nothing.
(requires authentication)
unstar($gist_id)
Unstars the given gist. By default uses the 'id' attribute defined in ->new.
Returns nothing.
(requires authentication)
PRIVATE METHODS
get_json_obj
post_json_obj
patch_json_obj
put_json_obj
delete_json_obj
basic_auth_header
AUTHOR
Alessandro Ghedini <alexbio@cpan.org>
LICENSE AND COPYRIGHT
Copyright 2011 Alessandro Ghedini.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.