=encoding utf8
=head1 NAME
Pastebin::Gist - Perl 6 interface to https://gist.github.com/
=head1 SYNOPSIS
use Pastebin::Gist;
my $p = Pastebin::Gist.new(
token => '3f2b4ca292960fafc63fb6798f148e3b47ea9fff',
);
my $paste_url = $p.paste("bar");
my $paste_url = $p.paste(
{
'file1.p6' => { content => "Paste content 1" },
'meow.css' => { content => "Paste content 2" },
},
desc => "Foo Bar",
public => 0,
);
=head1 DESCRIPTION
This module allows to paste to create GitHub Gists as retrieve them.
=head1 METHODS
=head2 C
# Assuming PASTEBIN_GIST_TOKEN env var has the token:
my $p = Pastebin::Gist.new;
# Set token via an argument:
my $p = Pastebin::Gist.new(
token => '3f2b4ca292960fafc63fb6798f148e3b47ea9fff',
)
Creates new C object. Accepts the following settings:
=head3 C
token => '3f2b4ca292960fafc63fb6798f148e3b47ea9fff'
B. To use this module you need to
L. Only the C
permission is needed.
You can avoid providing the C argument by setting the
C environmental variable to the value of your token.
=head2 C
my $paste_url = $p.paste('Paste content');
my $paste_url = $p.paste('Paste content', filename => 'foo.p6');
my $paste_url = $p.paste(
{
'file1.p6' => { content => "Paste content 1" },
'meow.css' => { content => "Paste content 2" },
},
desc => 'Optional summary',
public => True,
);
B URL to the created paste (e.g.
L).
First positional argument can either be a string of content to paste or
a hashref where keys are filenames and values are hashrefs with
values key C set to content of files to paste. Using a hashref
allows you to make a gist with multiple files. All other arguments
are optional and are as follows:
=head3 C
desc => 'Optional summary',
B. Provides the description (summary) of the gist. By default
not specified.
=head3 C
public => True,
B. Takes C or C values. If set to C, your
gist will be visible in search results and I page.
B C.
=head3 C
filename => "Foo.p6"
B. Applies only when the first positional argument to
L is a string. Specifies the filename to use for your gist
(affects syntax highlighting). B C.
Note: L
have this blurb in them:
Don't name your files "gistfile" with a numerical suffix.
This is the format of the automatic naming scheme that
Gist uses internally.
It tells you not to use files C or C. Behaviour
when using this types of values for C is not defined.
=head2 C
my ( $files, $desc )
= $p.fetch('https://gist.github.com/5590bc07b8d5bd8fd98d');
my ( $files, $desc ) = $p.fetch('5590bc07b8d5bd8fd98d');
say "Title: $desc";
for $files.keys {
say "File: $_\nContent:\n$files{$_}";
}
B a two-item list: files in the gist and gist's title.
B one mandatory argument: a full URL or just the
ID number of the gist you want to retrieve. The C<$files> is a hashref,
where keys are file names and values are the file's contents.
=head1 REPOSITORY
Fork this module on GitHub:
L
=head1 BUGS
To report bugs or request features, please use
L
=head1 AUTHOR
Zoffix Znet L
=head1 LICENSE
You can use and distribute this module under the same terms as Perl 6
itself. See the C file included in this distribution for complete
details.
=cut