| 1 | package Dancer::Deprecation; | ||||||||||
| 2 | 244 | our $AUTHORITY = 'cpan:SUKRIA'; | |||||||||
| 3 | #ABSTRACT: handle deprecation messages | ||||||||||
| 4 | 244 | $Dancer::Deprecation::VERSION = '1.3522'; | |||||||||
| 5 | 244 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 244 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 244 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 244 | ▶ | use Dancer::Exception qw(:all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 5 | ▶ | sub deprecated { | ||||||||
|
Subroutine
deprecated: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||
| 11 | 5 | my ($class, %args) = @_; | |||||||||
| 12 | |||||||||||
| 13 | 5 | my ( $package, undef, undef, $sub ) = caller(1); | |||||||||
| 14 | |||||||||||
| 15 | 5 | ▶ | unless ( defined $args{feature} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 3 | $args{feature} = $sub; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 5 | ▶ | my $deprecated_at = defined $args{version} ? $args{version} : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | |||||||||||
| 21 | 5 | my $msg; | |||||||||
| 22 | 5 | ▶ | if ( defined $args{message} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 2 | $msg = $args{message}; | |||||||||
| 24 | } | ||||||||||
| 25 | else { | ||||||||||
| 26 | 3 | $msg = "$args{feature} has been deprecated"; | |||||||||
| 27 | } | ||||||||||
| 28 | 5 | ▶ | $msg .= " since version $deprecated_at" if defined $deprecated_at; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 5 | ▶ | $msg .= ". " . $args{reason} if defined $args{reason}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 5 | ▶ | raise core_deprecation => $msg if $args{fatal}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 4 | carp($msg); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 244 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||