blib/lib/App/Nopaste/Service/Dancebin.pm

filter: Statementstmt 42.8% 15 / 35 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 44.4% 4 / 9 Podpod 100% 4 / 4 totaltotal 37.7% 23 / 61 CC 7 SCAR 21.0
CC
7
Cov
32%
fill_form
20.0
uri
6.0
get
6.0
CRAP 8.1
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package App::Nopaste::Service::Dancebin;
4 {
5 1 $App::Nopaste::Service::Dancebin::VERSION = '0.004';
6 }
7 1 ▶use Encode qw( decode_utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use base q[App::Nopaste::Service];
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: nopaste service for L<Dancebin>
12  
13 0 ▶sub uri { $ENV{DANCEBIN_URL} || 'http://danceb.in/' }
Subroutine uri: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"DANCEBIN_URL"} or "http://danceb.in/" 0 0 0
14  
15 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
16 0 my ($self, $mech) = @_;
17  
18 # Set BasicAuth credentials if needed
19 0 ▶ $mech->credentials( $self->_credentials ) if $self->_credentials;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_credentials 0 0 0
20  
21 0 return $mech->get($self->uri);
22 }
23  
24 0 ▶sub fill_form {
Subroutine fill_form: not called CC=4 SCAR=30.0
Pod documented
25 0 my ($self, $mech) = (shift, shift);
26 0 my %args = @_;
27  
28 my $content = {
29 code => decode_utf8($args{text}),
30 title => decode_utf8($args{desc}),
31 0 lang => decode_utf8($args{lang}),
32 };
33 0 my $exp = $ENV{DANCEBIN_EXP};
34 0 ▶ $content->{expiration} = $exp if $exp;
Branch: 1 branch
BranchTrueFalseTotal
if $exp 0 0 0
35  
36 # Set BasicAuth credentials if needed
37 0 ▶ $mech->credentials( $self->_credentials ) if $self->_credentials;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_credentials 0 0 0
38  
39 0 ▶ my $form = $mech->form_number(1) || return;
Condition0%0/2
$mech->form_number(1) || (return)
l!l
00
MC/DC0%0/1
$mech->form_number(1) || (return)
$mech->form_number(1)
Truth table0%0/2
A
A= $mech->form_number(1)
Aresult
11
00
40  
41 # do not follow redirect please
42 0 @{$mech->requests_redirectable} = ();
43  
44 0 my $paste = HTML::Form::Input->new(
45 type => 'text',
46 value => 'Send',
47 name => 'paste'
48 )->add_to_form($form);
49  
50 0 return $mech->submit_form( form_number => 1, fields => $content );
51 }
52  
53 0 ▶sub return {
Subroutine return: not called CC=2 SCAR=17.9
Pod documented
54 0 my ( $self, $mech ) = @_;
55  
56 0 ▶ if($mech->response->is_redirect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mech->response->is_redirect) { } 0 0 0
57 0 return ( 1, $mech->response->header("Location") );
58 } else {
59 0 return ( 0, "Cannot find URL" );
60 }
61 }
62  
63 0 ▶sub _credentials { ($ENV{DANCEBIN_USER}, $ENV{DANCEBIN_PASS}) }
Subroutine _credentials: not called CC=1 SCAR=6.9
64  
65 1 1;
66  
67  
68 __END__
↑ Summary