| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 35 | |||||||||||||
| 36 | # Set BasicAuth credentials if needed | ||||||||||||
| 37 | 0 | ▶ | $mech->credentials( $self->_credentials ) if $self->_credentials; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | |||||||||||||
| 39 | 0 | ▶ | my $form = $mech->form_number(1) || return; | ||||||||||
|
Condition0%0/2
$mech->form_number(1) || (return)
MC/DC0%0/1
$mech->form_number(1) || (return)
$mech->form_number(1)
Truth table0%0/2
A
A= $mech->form_number(1)
| |||||||||||||
| 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
| |||||||||||||
| 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__ | ||||||||||||