NAME
WWW::Pastebin::RafbNet::Create - create new pastes on http://rafb.net/
SYNOPSIS
use WWW::Pastebin::RafbNet::Create;
my $paster = WWW::Pastebin::RafbNet::Create->new;
$paster->paste( $text )
or die $paster->error;
print "Your paste can be found on $paster\n";
DESCRIPTION
The module provides means to create new pastes on http://rafb.net/ paste site.
The WWW::Rafb module offers a similiar functionality. However, it does not pass the test suite, and the author does not seem to care (last update was close to a year ago). As well, the module seems to have a bit of an "uncomfortable" interface, including not being able to paste text from a scalar easily.
CONSTRUCTOR
new
my $paster = WWW::Pastebin::RafbNet::Create->new;
my $paster = WWW::Pastebin::RafbNet::Create->new(
timeout => 10,
);
my $paster = WWW::Pastebin::RafbNet::Create->new(
ua => LWP::UserAgent->new(
timeout => 10,
agent => 'PasterUA',
),
);
Constructs and returns a brand new yummy juicy WWW::Pastebin::RafbNet::Create object. Takes two arguments, both are optional. Possible arguments are as follows:
timeout
->new( timeout => 10 );
Optional. Specifies the timeout
argument of LWP::UserAgent's constructor, which is used for pasting. Defaults to: 30
seconds.
ua
->new( ua => LWP::UserAgent->new( agent => 'Foos!' ) );
Optional. If the timeout
argument is not enough for your needs of mutilating the LWP::UserAgent object used for pasting, feel free to specify the ua
argument which takes an LWP::UserAgent object as a value. Note: the timeout
argument to the constructor will not do anything if you specify the ua
argument as well. Defaults to: plain boring default LWP::UserAgent object with timeout
argument set to whatever WWW::Pastebin::RafbNet::Create
's timeout
argument is set to as well as agent
argument is set to mimic Firefox.
METHODS
paste
$paster->paste( 'lotsa text' )
or die $paster->error;
$paster->paste(
'lotsa text',
nick => 'Zoffix',
desc => 'some text',
tabs => 8,
lang => 'Perl',
) or die $paster->error;
Instructs the object to create a new paste on http://rafb.net/paste/. On success returns an URI object pointing to a newly created paste, but you don't have to store it, see uri()
method which is also overloaded for this module. On failure returns either undef
or an empty list depending on the context and the reason for error will be available via error()
method.
Takes one mandatory argument, as well as several key/value optional arguments. The first argument is a scalar contaning the text you want to paste. The optional key/value arguments are as follows:
nick
$paster->paste( 'text', nick => 'Zoffix' )
Optional. Takes a scalar contaning the nick of the poster. By default is not specified resulting in Anonymous
as nick.
desc
$paster->paste( 'text', desc => 'some description' )
Optional. Takes a scalar contaning the description of the paste. By default is not specified (no description).
tabs
$paster->paste( 'text', tabs => '8' )
Optional. Takes a scalar contaning either no
, 2
, 3
, 4
, 5
6
or 8
. Tells the pastebin to convert any tab characters to spaces, each tab should be replaced by spaces. The number of spaces per tab is specified as the value of tabs
argument. The no
value tells that no conversion should be done. Defaults to: no
lang
$paster->paste( 'text', lang => 'Perl' )
Optional. Takes a scalar contaning a language "code" specifying the language of the paste (effectively turning appropriate syntax highlights on it). Defaults to: 'plain text'
. Possible language codes are case-insensitive and are as follows, the left side represents the code to be used for lang
argument and the right side is the language's name:
c89 => 'C (C89)',
c => 'C (C99)',
'c++' => 'C++',
'c#' => 'C#',
'java' => 'Java',
pascal => 'Pascal',
perl => 'Perl',
php => 'PHP',
'pl/i' => 'PL/I',
python => 'Python',
ruby => 'Ruby',
sql => 'SQL',
vb => 'Visual Basic',
'plain text wrap' => 'Word wrapped text',
'plain text' => 'Plain Text',
error
$paster->paste( 'lotsa text' )
or die $paster->error;
If paste()
method fails it will return either undef
or an empty list depending on the context and the reason for the error will be available via error()
method. Takes no arguments, returns a human readable error message describing why paste()
failed.
paste_uri
printf "Paste is at: %s\n", $paster->paste_uri;
# or
print "Paste is at: $paster\n";
Must be called after a successfull call to paste()
. Takes no arguments, returns a URI object pointing to a newly created paste. The module provides overload, thus instead of calling the paste_uri()
method or storing the value of paster()
method you could simply use WWW::Pastebin::RafbNet::Create
object in a string.
response
my $http_response_obj = $paster->response;
Must be called after a call to paste()
. Takes no arguments, returns a HTTP::Response object obtained when a new was created. You can use this if you want to further investigate why paste()
method failed.
timeout
my $timeout = $paster->timeout;
Takes no arguments, returns whatever you've specified in the timeout
argument in the constructor (new()
) or its default if you didn't specify anything.
ua
my $ua = $paster->ua;
$paster->ua( LWP::UserAgent->new( timeout => 10, agent => 'MOOO!' );
Returns an LWP::UserAgent object used for pasting by the module. Takes one optional argument which should be an LWP::UserAgent object. If called with an argument the LWP::UserAgent object you specify will be used in any subsequent pasting.
SEE ALSO
LWP::UserAgent, HTTP::Response
AUTHOR
Zoffix Znet, <zoffix at cpan.org>
(http://zoffix.com, http://haslayout.net)
BUGS
Please report any bugs or feature requests to bug-www-pastebin-rafbnet-create at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Pastebin-RafbNet-Create. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc WWW::Pastebin::RafbNet::Create
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Pastebin-RafbNet-Create
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
Copyright 2008 Zoffix Znet, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.