NAME
WWW::GitHub::Gist - Perl interface to GitHub's Gist pastebin service
VERSION
version 0.07
SYNOPSIS
WWW::GitHub::Gist is an object-oriented interface to the pastebin service of GitHub gist.github.com.
use feature 'say';
use WWW::GitHub::Gist;
my $gist = WWW::GitHub::Gist -> new(id => 'gist id');
# Print the gist's author
say $gist -> info -> {'owner'};
# Print every ID of the gists owned by USERNAME
$gist = WWW::GitHub::Gist -> new(user => 'USERNAME');
foreach (@{ $gist -> user() }) {
say $_ -> {'repo'};
}
# Create a new gist and print its ID
my $login = `git config github.user`;
my $token = `git config github.token`;
chomp $login; chomp $token;
$gist = WWW::GitHub::Gist -> new(
user => $login,
token => $token
);
$gist -> add_file('test', 'some data here', '.txt');
say $gist -> create() -> {'repo'};
METHODS
new( %args )
Create a WWW::GitHub::Gist object. The %args
hash may contain the following fields:
id
-
The ID of an existing gist.
user
-
The name of a GitHub user.
token
-
The GitHub token used for the login.
info()
Returns an hash containing the following fields:
owner
-
The author of the gist.
created_at
-
The date of creation of the gist.
repo
-
The ID of the gist, which identifies its repository.
files
-
An array of the file names contained in the gist.
public
-
Wheter the gist is public or not.
description
-
The description of the gist.
file( $filename )
Retrieve the selected file content of the current gist.
user()
Retrieve user's gists
add_file( $filename, $data, $extension )
Add a file to the current gist
create
Create a gist using files added with add_file() and returns its info in a hash. See info()
for more details.
INTERNAL SUBROUTINES
_parse_response( $data )
Parse the response of an HTTP request.
EXTENSION
The extension variable is used by GitHub to set proper syntax highlighting rules.
GitHub supports the following extensions/languages:
.txt Plain Text
.as ActionScript
.c C
.cs C#
.cpp C++
.css CSS
.cl Common Lisp
.diff Diff
.el Emacs Lisp
.hrl Erlang
.html HTML
.hs Haskell
.java Java
.js JavaScript
.lua Lua
.m Objective-C
.php PHP
.pl Perl
.py Python
.rb Ruby
.sql SQL
.scala Scala
.sls Scheme
.tex TeX
.xml XML
.ascx ASP
.scpt AppleScript
.arc Arc
.asm Assembly
.bat Batchfile
.befunge Befunge
.boo Boo
.b Brainfuck
.ck ChucK
.clj Clojure
.coffee CoffeeScript
.cfm ColdFusion
.feature Cucumber
.d D
.darcspatch Darcs Patch
.pas Delphi
.duby Duby
.dylan Dylan
.e Eiffel
.f FORTRAN
.s GAS
.kid Genshi
.ebuild Gentoo Ebuild
.eclass Gentoo Eclass
.po Gettext Catalog
.go Go
.man Groff
.mustache HTML+Django
.erb HTML+ERB
.phtml HTML+PHP
.hx HaXe
.haml Haml
.ini INI
.weechatlog IRC log
.io Io
.ll LLVM
.mak Makefile
.mao Mako
.ron Markdown
.matlab Matlab
.mxt Max/MSP
.md MiniD
.moo Moocode
.myt Myghty
.nu Nu
.numpy NumPy
.ml OCaml
.j Objective-J
.pir Parrot Internal Representation
.pd Pure Data
.pytb Python traceback
.r R
.rhtml RHTML
.raw Raw token data
.cw Redcode
.sass Sass
.self Self
.sh Shell
.st Smalltalk
.tpl Smarty
.sc SuperCollider
.tcl Tcl
.tcsh Tcsh
.txt Text
.vhdl VHDL
.v Verilog
.vim VimL
.bas Visual Basic
.yml YAML
.jsp jsp
.mu mupad
.ooc ooc
.rst reStructuredText
ACKNOWLEDGEMENTS
Gist.GitHub.com APIs are incomplete, so many features are not accessible.
WWW::GitHub::Gist used to provide a gist
script, which is now available in the stand-alone distribution App::gist
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.