| 1 | package MooseX::Declare::Context::WithOptions::Patch::Extensible; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 2 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | $MooseX::Declare::Context::WithOptions::Patch::Extensible::AUTHORITY = 'cpan:TOBYINK'; | |||||||||||
| 10 | 2 | $MooseX::Declare::Context::WithOptions::Patch::Extensible::VERSION = '0.002'; | |||||||||||
| 11 | } | ||||||||||||
| 12 | |||||||||||||
| 13 | # I had hoped to do this with Module::Patch, but it seems that Module::Patch | ||||||||||||
| 14 | # doesn't work especially well with Moose roles. Patching a sub in the role | ||||||||||||
| 15 | # does not necessarily affect the classes that the role has been composed with. | ||||||||||||
| 16 | |||||||||||||
| 17 | 2 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 2 | ▶ | use MooseX::Declare::Context::WithOptions 0.22; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | |||||||||||||
| 20 | sub import | ||||||||||||
| 21 | 2 | ▶ | { | ||||||||||
|
Subroutine
import: called CC=2 SCAR=7.6
| |||||||||||||
| 22 | 2 | ▶ | carp "MooseX::Declare::Context::WithOptions->VERSION gt '0.35'" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | if MooseX::Declare::Context::WithOptions->VERSION gt '0.35'; | ||||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | { | ||||||||||||
| 27 | package # hide from CPAN indexer | ||||||||||||
| 28 | MooseX::Declare::Context::WithOptions; | ||||||||||||
| 29 | |||||||||||||
| 30 | 2 | ▶ | use Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | 2 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 32 | |||||||||||||
| 33 | 2 | ▶ | no warnings 'redefine'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 34 | |||||||||||||
| 35 | has allowed_option_names => ( | ||||||||||||
| 36 | is => 'rw', | ||||||||||||
| 37 | isa => 'ArrayRef', | ||||||||||||
| 38 | lazy => 1, | ||||||||||||
| 39 | 1 | ▶ | default => sub { [qw[ extends with is ]] }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 40 | 2 | ); | |||||||||||
| 41 | |||||||||||||
| 42 | 1 | ▶ | sub strip_options { | ||||||||||
|
Subroutine
strip_options: called CC=10 SCAR=26.3
Pod
undocumented
| |||||||||||||
| 43 | 1 | my ($self) = @_; | |||||||||||
| 44 | 1 | my %ret; | |||||||||||
| 45 | |||||||||||||
| 46 | # Make errors get reported from right place in source file | ||||||||||||
| 47 | 1 | local $Carp::Internal{'MooseX::Declare'} = 1; | |||||||||||
| 48 | 1 | local $Carp::Internal{'Devel::Declare'} = 1; | |||||||||||
| 49 | |||||||||||||
| 50 | 1 | $self->skipspace; | |||||||||||
| 51 | 1 | my $linestr = $self->get_linestr; | |||||||||||
| 52 | |||||||||||||
| 53 | 1 | ▶ | while (substr($linestr, $self->offset, 1) !~ /[{;]/) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 54 | 2 | my $key = $self->strip_name; | |||||||||||
| 55 | 2 | ▶ | if (!defined $key) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 56 | 0 | ▶ | croak 'expected option name' | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 57 | if keys %ret; | ||||||||||||
| 58 | 0 | return; # This is the case when { class => 'foo' } happens | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | croak "unknown option name '$key'" | ||||||||||||
| 62 | 2 | ▶ | unless grep { $key eq $_ } @{ $self->allowed_option_names }; ##DIFF | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | |||||||||||||
| 64 | 2 | my $val = $self->strip_name; | |||||||||||
| 65 | 2 | ▶ | if (!defined $val) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | 0 | ▶ | if (defined($val = $self->strip_proto)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 67 | 0 | $val = [split /\s*,\s*/, $val]; | |||||||||||
| 68 | } | ||||||||||||
| 69 | else { | ||||||||||||
| 70 | 0 | croak "expected option value after $key"; | |||||||||||
| 71 | } | ||||||||||||
| 72 | } | ||||||||||||
| 73 | |||||||||||||
| 74 | 2 | ▶ | $ret{$key} ||= []; | ||||||||||
|
Condition100%2/2
$ret{$key} ||= []
MC/DC100%1/1
$ret{$key} ||= []
$ret{$key}
Truth table100%2/2
A
A= $ret{$key}
| |||||||||||||
| 75 | 0 | ▶ | push @{ $ret{$key} }, ref $val ? @{ $val } : $val; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 76 | } continue { | ||||||||||||
| 77 | 2 | $self->skipspace; | |||||||||||
| 78 | 2 | $linestr = $self->get_linestr(); | |||||||||||
| 79 | } | ||||||||||||
| 80 | |||||||||||||
| 81 | my $options = { map { | ||||||||||||
| 82 | 1 | my $key = $_; | |||||||||||
| 83 | $key eq 'is' | ||||||||||||
| 84 | 0 | ? ($key => { map { ($_ => 1) } @{ $ret{$key} } }) | |||||||||||
| 85 | 1 | ▶ | : ($key => $ret{$key}) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 86 | } keys %ret }; | ||||||||||||
| 87 | |||||||||||||
| 88 | 1 | $self->options($options); | |||||||||||
| 89 | |||||||||||||
| 90 | 1 | return $options; | |||||||||||
| 91 | } | ||||||||||||
| 92 | } | ||||||||||||
| 93 | |||||||||||||
| 94 | 2 | 1; | |||||||||||
| 95 | |||||||||||||
| 96 | __END__ | ||||||||||||