Net::G...:Gists(3pm)

πŸ“¦
version 1.05 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… NAME

okay so bestie, this is Net::GitHub::V3::Gists β€” it's the GitHub Gists API, wrapped up all cute for you in Perl. No cap. πŸŽ€


✨ SYNOPSIS ✨

use Net::GitHub::V3;

my $gh = Net::GitHub::V3->new; # read L<Net::GitHub::V3> to set right authentication info
my $gist = $gh->gist;

like, that's the whole vibe check right there. you make the $gh object, then you grab $gist off it and go off. πŸ‘‘


🌸 DESCRIPTION 🌸

πŸ¦‹ METHODS πŸ¦‹

🌈 Git Data

<http://developer.github.com/v3/gists/> β€” the docs, if you wanna read the source material iykyk.

⭐ gists

my @gists = $gist->gists;
my @gists = $gist->gists('nothingmuch');
while (my $g = $gist->next_gist) { ...; }

pass a username if you want, or don't. next_gist loops through them one at a time like a lil conveyor belt of gists. πŸ”₯

⭐ public_gists

⭐ starred_gists

my @gists = $gist->public_gists;
my @gists = $gist->starred_gists;
while (my $g = $gist->next_public_gist) { ...; }
while (my $g = $gist->next_starred_gist) { ...; }

same energy, different feed: public ones and the ones you starred. each has its own next_ iterator, obviously. πŸ’–

⭐ gist

my $gist = $gist->gist($gist_id);

grab one specific gist by its $gist_id. main character energy, singular. 🌟

⭐ create

my $gist = $gist->create( {
  "description" => "the description for this gist",
  "public" => 'true',
  "files"  =>  {
    "file1.txt" => {
        "content" => "String file contents"
    }
  }
} );

make a brand new gist bestie!! you gotta hand it a hashref with a description, whether it's public (note: the string 'true' here, not a real boolean, don't come for me), and a files hashref where each filename maps to a hashref holding its content. copy it exactly, fr fr. ✨

⭐ update

my $g = $gist->update( $gist_id, {
    description => "edited desc"
} );

edit an existing gist β€” give it the $gist_id plus a hashref of what you're changing. glow-up time. πŸ’…

⭐ star

⭐ unstar

⭐ is_starred

my $st = $gist->star($gist_id);
my $st = $gist->unstar($gist_id);
my $st = $gist->is_starred($gist_id);

star to bless it, unstar to un-bless it (heartbreaking, i know 😭), is_starred to check whether the blessing is currently active. all three just take $gist_id. 🫢

⭐ fork

⭐ delete

my $g  = $gist->fork($gist_id);
my $st = $gist->delete($gist_id);

fork copies someone's gist into your own little corner of the internet. delete... deletes it. gone. poof. πŸ’€ takes $gist_id, both of them.


🌈 Gist Comments API

<http://developer.github.com/v3/gists/comments/> β€” more docs, go look if you're curious. πŸ”

⭐ comments

⭐ comment

⭐ create_comment

⭐ update_comment

⭐ delete_comment

my @comments = $gist->comments();
while (my $c = $gist->next_comment) { ...; }
my $comment  = $gist->comment($comment_id);
my $comment  = $gist->create_comment($gist_id, {
    "body" => "a new comment"
});
my $comment = $gist->update_comment($gist_id, $comment_id, {
    "body" => "Nice change"
});
my $st = $gist->delete_comment($gist_id, $comment_id);

the comment era πŸŽ€ β€” comments() pulls them all, next_comment iterates them one by one, comment($comment_id) grabs a single one, create_comment needs a $gist_id and a hashref with a body, update_comment needs the $gist_id, the $comment_id and the new body, and delete_comment needs the $gist_id and $comment_id to yeet it into the void. 🌈


just go refer to Net::GitHub, bestie β€” it's all there. πŸ“š


and that's the whole page!! this one shipped with perl v5.36.0 back on 2022-10-08, so if you're running something ancient that's on you πŸ™ˆ. stay iconic, go make some gists, mwah πŸ’œ

πŸ“¦ where this page comes from