blib/lib/App/Nopaste/Service/Pastedance.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 47 CC 2 SCAR 11.0
CC
2
Cov
0%
return
6.0
uri
2.0
fill_form
2.0
CRAP 3.0
1 package App::Nopaste::Service::Pastedance;
2  
3 use warnings;
4 use strict;
5 use Encode;
6  
7 our $VERSION = '0.04';
8  
9 use base q[App::Nopaste::Service];
10  
11 sub uri { $ENV{PASTEDANCE_URL} || 'http://paste.perldancer.org/' }
12  
13 sub fill_form {
14 my ($self, $mech) = (shift, shift);
15 my %args = @_;
16  
17 my $content = {
18 code => decode('UTF-8', $args{text}),
19 subject => decode('UTF-8', $args{desc}),
20 # Pastedance itself defaults to txt if <lang> is not known
21 lang => $args{lang},
22 };
23  
24 my $form = $mech->form_number(1) || return;
25  
26 # do not follow redirect please
27 @{$mech->requests_redirectable} = ();
28  
29 my $paste = HTML::Form::Input->new(
30 type => 'text',
31 value => 'Send',
32 name => 'paste'
33 )->add_to_form($form);
34  
35 return $mech->submit_form( form_number => 1, fields => $content );
36 }
37  
38 sub return {
39 my $self = shift;
40 my $mech = shift;
41 my $response = $mech->response;
42 if($response->is_redirect) {
43 return (1,$response->header("Location"));
44 } else {
45 return (0, "Cannot find URL");
46 }
47 }
48  
49 1;
50 __END__