| 1 | 1 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Data::Semantic::RegexpAdapter; | ||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | $Data::Semantic::RegexpAdapter::VERSION = '1.101620'; | |||||||||
| 8 | } | ||||||||||
| 9 | |||||||||||
| 10 | # ABSTRACT: Adapter for Regexp::Common patterns | ||||||||||
| 11 | 1 | ▶ | use Regexp::Common; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use parent qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | Data::Semantic | ||||||||||
| 14 | Data::Inherited | ||||||||||
| 15 | 1 | ); | |||||||||
| 16 | 1 | __PACKAGE__->mk_scalar_accessors(qw(re))->mk_boolean_accessors(qw(keep)) | |||||||||
| 17 | ->mk_hash_accessors(qw(kept)); | ||||||||||
| 18 | 1 | ▶ | use constant LOAD => ''; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use constant REGEXP_KEYS => (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 1 | ▶ | use constant KEEP_KEYS => (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub init { | ||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 23 | 0 | my $self = shift; | |||||||||
| 24 | 0 | ▶ | Regexp::Common->import($self->LOAD) if $self->LOAD; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | my @regexp_keys = $self->every_list('REGEXP_KEYS'); | |||||||||
| 26 | 0 | ▶ | @regexp_keys || die "REGEXP_KEYS is not defined"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | my $re_spec = sprintf '$RE%s', join '' => map { "{$_}" } @regexp_keys, | |||||||||
| 28 | $self->flags; | ||||||||||
| 29 | 0 | my $re = eval $re_spec; | |||||||||
| 30 | 0 | ▶ | die $@ if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | $self->re($re); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | # turn the object's settings into a list of flags to be passed to | ||||||||||
| 35 | # Regexp::Common's $RE | ||||||||||
| 36 | 0 | ▶ | sub flags { | ||||||||
|
Subroutine
flags: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 37 | 0 | my $self = shift; | |||||||||
| 38 | 0 | my @flags; | |||||||||
| 39 | 0 | ▶ | push @flags => '-keep' if $self->keep; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | @flags; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub is_valid_normalized_value { | ||||||||
|
Subroutine
is_valid_normalized_value: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 44 | 0 | my ($self, $value) = @_; | |||||||||
| 45 | 0 | my $re = $self->re; | |||||||||
| 46 | 0 | my $ok = $value =~ /^$re$/; | |||||||||
| 47 | |||||||||||
| 48 | # assume {-keep} was given in any case - the user will know whether kept() | ||||||||||
| 49 | # will return anything useful. | ||||||||||
| 50 | 0 | my %keep; | |||||||||
| 51 | @keep{ $self->KEEP_KEYS } = | ||||||||||
| 52 | 0 | ▶ | map { defined($_) ? $_ : '' } ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 0 | $self->kept(%keep); | |||||||||
| 54 | 0 | $ok; | |||||||||
| 55 | } | ||||||||||
| 56 | 1 | 1; | |||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||