| 1 | package URL::Signature::Path; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use parent 'URL::Signature'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Params::Util qw( _NONNEGINT ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | our $VERSION = '0.03'; | |||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | 1 | my ($class, %attrs) = @_; | |||||||||
| 13 | 1 | return $class->SUPER::new( %attrs, format => 'path' ); | |||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 2 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||
| 17 | 2 | my $self = shift; | |||||||||
| 18 | 2 | ▶ | $self->{'as'} = 1 unless exists $self->{'as'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | Carp::croak( q[in 'path' format, 'as' needs to be a non-negative integer]) | ||||||||||
| 20 | 2 | ▶ | unless defined _NONNEGINT($self->{'as'}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | 2 | return; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | 3 | ▶ | sub extract { | ||||||||
|
Subroutine
extract: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 27 | 3 | my ($self, $uri) = @_; | |||||||||
| 28 | 3 | my @segments = $uri->path_segments; | |||||||||
| 29 | 3 | ▶ | return if scalar @segments <= $self->{'as'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 3 | my $code = splice @segments, $self->{'as'}, 1; | |||||||||
| 32 | 3 | $uri->path_segments( @segments ); | |||||||||
| 33 | |||||||||||
| 34 | 3 | return ($code, $uri); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | 3 | ▶ | sub append { | ||||||||
|
Subroutine
append: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 39 | 3 | my ($self, $uri, $code) = @_; | |||||||||
| 40 | 3 | my @segments = $uri->path_segments; | |||||||||
| 41 | 3 | ▶ | return if scalar @segments <= $self->{'as'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 3 | splice @segments, $self->{'as'}, 0, $code; | |||||||||
| 43 | 3 | $uri->path_segments(@segments); | |||||||||
| 44 | 3 | return $uri; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | 2 | 42; | |||||||||
| 49 | __END__ | ||||||||||