| 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::WerePaste; | ||||||||||
| 4 | { | ||||||||||
| 5 | 1 | $App::Nopaste::Service::WerePaste::VERSION = '0.02'; | |||||||||
| 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<WerePaste> | ||||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | sub uri { $ENV{WEREPASTE_URL} || 'http://paste.were.space/' } | ||||||||
|
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=3 SCAR=24.8
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{WEREPASTE_EXP}; | |||||||||
| 34 | 0 | ▶ | $content->{expiration} = $exp if $exp; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | ▶ | $mech->credentials( $self->_credentials ) if $self->_credentials; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | @{$mech->requests_redirectable} = (); | |||||||||
| 37 | |||||||||||
| 38 | 0 | return $mech->submit_form( form_number => 1, fields => $content ); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub return { | ||||||||
|
Subroutine
return: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 42 | 0 | my ( $self, $mech ) = @_; | |||||||||
| 43 | 0 | ▶ | return (1, $mech->response->header('Location')) if $mech->response->is_redirect; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | return (0, 'Cannot find URL'); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub _credentials { ($ENV{WEREPASTE_USER}, $ENV{WEREPASTE_PASS}) } | ||||||||
|
Subroutine
_credentials: not called CC=1 SCAR=6.9
| |||||||||||
| 48 | |||||||||||
| 49 | 1 | 1; | |||||||||
| 50 | __END__ | ||||||||||