Padre::Plugin::Nopaste::Task - Padre::Plugin::Nopaste::Task documentation


Padre-Plugin-Nopaste documentation Contained in the Padre-Plugin-Nopaste distribution.

Index


Code Index:

NAME

Top

Padre::Plugin::Nopaste::Task

SYNOPSIS

Top

DESCRIPTION

Top

Async thread that does real nopaste

Standard Padre::Task API

Top

In order not to freeze Padre during web access, nopasting is done in a thread, as implemented by Padre::Task. Refer to this module's documentation for more information.

The following methods are implemented:

* prepare()
* process()
* run()

AUTHOR

Top

Alexandr Ciornii, Jerome Quelin, <jquelin@cpan.org>

COPYRIGHT AND LICENSE

Top


Padre-Plugin-Nopaste documentation Contained in the Padre-Plugin-Nopaste distribution.
package Padre::Plugin::Nopaste::Task;

use 5.008;
use strict;
use warnings;
use Padre::Task ();
use Padre::Logger;

our $VERSION = '0.3.1';
our @ISA     = 'Padre::Task';

sub prepare {
    my ($self) = @_;

    my $main     = $self->{document}->main;
    my $current  = $main->current;
    my $editor   = $current->editor;
    return unless $editor;

    # no selection means send current file
    $self->{text} = $editor->GetSelectedText || $editor->GetText;
}

sub run {
	my $self = shift;

	$self->process();

	return 1;
}

sub process {
    my ($self) = @_;

    require App::Nopaste;
    my $url = App::Nopaste::nopaste($self->{text});

    # show result in output section
    if ( defined $url ) {
        my $text = "Text successfully nopasted at: $url\n";
        $self->{err}=0;
        $self->{message}=$text;
    } else {
        my $text = "Error while nopasting text\n";
        $self->{err}=1;
        $self->{message}=$text;
    }
    return;
}

1;

__END__

# Copyright 2008-2010 The Padre development team as listed in Padre.pm.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.