| 1 | package Text::Xslate::Bridge::Star; | ||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use parent qw(Text::Xslate::Bridge); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=12.2
| |||||||||||||||||||||
| 7 | 2 | ▶ | if(my $code = re->can('is_regexp')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 8 | 2 | *_is_rx = $code; | |||||||||||||||||||
| 9 | } | ||||||||||||||||||||
| 10 | else { | ||||||||||||||||||||
| 11 | 0 | require Scalar::Util; | |||||||||||||||||||
| 12 | 0 | ▶ | *_is_rx = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 13 | 0 | ▶ | return Scalar::Util::blessed($_[0]) | ||||||||||||||||||
|
Condition0%0/3
builtin::blessed($_[0]) && $_[0]->isa('Regexp')
MC/DC0%0/2
builtin::blessed($_[0]) && $_[0]->isa('Regexp')
builtin::blessed($_[0])
$_[0]->isa('Regexp')
Truth table0%0/3
A && B
A= builtin::blessed($_[0])B= $_[0]->isa('Regexp')
| |||||||||||||||||||||
| 14 | && $_[0]->isa('Regexp'); | ||||||||||||||||||||
| 15 | 0 | }; | |||||||||||||||||||
| 16 | } | ||||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 6 | ▶ | sub lc { | ||||||||||||||||||
|
Subroutine
lc: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 20 | 6 | ▶ | return defined($_[0]) ? CORE::lc($_[0]) : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 6 | ▶ | sub uc { | ||||||||||||||||||
|
Subroutine
uc: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 24 | 6 | ▶ | return defined($_[0]) ? CORE::uc($_[0]) : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 8 | ▶ | sub substr { | ||||||||||||||||||
|
Subroutine
substr: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 28 | 8 | my($str, $offset, $length) = @_; | |||||||||||||||||||
| 29 | 8 | ▶ | return undef unless defined $str; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 6 | ▶ | $offset = 0 unless defined $offset; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | 6 | ▶ | $length = length($str) unless defined $length; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 6 | return CORE::substr($str, $offset, $length); | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 4 | ▶ | sub sprintf { | ||||||||||||||||||
|
Subroutine
sprintf: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 37 | 4 | my $fmt = shift; | |||||||||||||||||||
| 38 | 4 | ▶ | return undef unless defined $fmt; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 4 | ▶ | if(@_) { # sprintf($fmt, ...) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 2 | return sprintf $fmt, @_; | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | else { # $x | sprintf('%.02f') | ||||||||||||||||||||
| 43 | 2 | ▶ | return sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 44 | 2 | sprintf $fmt, @_; | |||||||||||||||||||
| 45 | 2 | }; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 12 | ▶ | sub rx { | ||||||||||||||||||
|
Subroutine
rx: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 50 | 12 | ▶ | return defined($_[0]) ? qr/$_[0]/ : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 10 | ▶ | sub match { | ||||||||||||||||||
|
Subroutine
match: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 54 | 10 | my($str, $pattern) = @_; | |||||||||||||||||||
| 55 | 10 | ▶ | return undef unless defined $str; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | 8 | ▶ | return undef unless defined $pattern; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 8 | ▶ | $pattern = quotemeta($pattern) unless _is_rx($pattern); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | 8 | return scalar($str =~ m/$pattern/); | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 8 | ▶ | sub replace { | ||||||||||||||||||
|
Subroutine
replace: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||
| 63 | 8 | my($str, $pattern, $replacement) = @_; | |||||||||||||||||||
| 64 | 8 | ▶ | return undef unless defined $str; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | 8 | ▶ | return undef unless defined $pattern; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 8 | ▶ | $pattern = quotemeta($pattern) unless _is_rx($pattern); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | 8 | $str =~ s/$pattern/$replacement/g; | |||||||||||||||||||
| 69 | 8 | return $str; | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 12 | ▶ | sub split { | ||||||||||||||||||
|
Subroutine
split: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 73 | 12 | my($str,$pattern,$limit) = @_; | |||||||||||||||||||
| 74 | 12 | ▶ | if (!defined $pattern) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | 2 | $pattern = ' '; | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | 12 | ▶ | $pattern = quotemeta($pattern) unless _is_rx($pattern); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 12 | ▶ | if (defined $limit) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 79 | 2 | return [CORE::split($pattern, $str, $limit)]; | |||||||||||||||||||
| 80 | } else { | ||||||||||||||||||||
| 81 | 10 | return [CORE::split($pattern, $str)]; | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 2 | my %scalar_methods = ( | |||||||||||||||||||
| 86 | lc => \&lc, | ||||||||||||||||||||
| 87 | uc => \&uc, | ||||||||||||||||||||
| 88 | substr => \&substr, | ||||||||||||||||||||
| 89 | sprintf => \&sprintf, | ||||||||||||||||||||
| 90 | rx => \&rx, | ||||||||||||||||||||
| 91 | match => \&match, | ||||||||||||||||||||
| 92 | replace => \&replace, | ||||||||||||||||||||
| 93 | split => \&split, | ||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 2 | __PACKAGE__->bridge( | |||||||||||||||||||
| 97 | # nil => \%nil_methods, | ||||||||||||||||||||
| 98 | scalar => \%scalar_methods, | ||||||||||||||||||||
| 99 | # array => \%array_methods, | ||||||||||||||||||||
| 100 | # hash => \%hash_methods, | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | function => \%scalar_methods, | ||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 2 | 1; | |||||||||||||||||||
| 106 | __END__ | ||||||||||||||||||||