App::Nopaste::Service::Codepeek - http://codepeek.com


App-Nopaste documentation Contained in the App-Nopaste distribution.

Index


Code Index:

NAME

Top

App::Nopaste::Service::Codepeek - http://codepeek.com

AUTHOR

Top

Justin Hunter, <justin.d.hunter@gmail.com>


App-Nopaste documentation Contained in the App-Nopaste distribution.

package App::Nopaste::Service::Codepeek;
use strict;
use warnings;
use base 'App::Nopaste::Service';

sub uri { 'http://codepeek.com/paste' }

sub fill_form {
    my $self = shift;
    my $mech = shift;
    my %args = @_;

    $mech->form_number(1);

    $mech->submit_form(
        fields => {
            'paste'    => $args{text},
            'language' => ucfirst $args{lang},
        },
    );
}

sub return {
    my $self = shift;
    my $mech = shift;

    my $link = $mech->find_link( text_regex => qr#^http://codepeek.com/paste/[a-z0-9]+$#i );
    my $url = $link->url;
    return (0, "Could not construct paste link.") if !$url;
    return (1, $url);
}

1;

__END__