| 1 | package Perl::ToPerl6::TransformerConfig; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 25 | ▶ | use 5.006001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 25 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 25 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 25 | ▶ | use Perl::ToPerl6::Exception::AggregateConfiguration; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 25 | ▶ | use Perl::ToPerl6::Exception::Configuration::Option::Transformer::ParameterValue; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 25 | ▶ | use Perl::ToPerl6::Exception::Configuration::Option::Transformer::ExtraParameter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 25 | ▶ | use Perl::ToPerl6::Utils qw< :booleans :characters necessity_to_number >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 25 | ▶ | use Perl::ToPerl6::Utils::Constants qw< :profile_strictness >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 25 | Readonly::Scalar my $NON_PUBLIC_DATA => '_non_public_data'; | |||||||||||||||||||||||||||
| 18 | 25 | Readonly::Scalar my $NO_LIMIT => 'no_limit'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2771 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 2771 | my ($class, $transformer_short_name, $specification) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 2771 | ▶ | my %self = $specification ? %{ $specification } : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 2771 | my %non_public_data; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2771 | $non_public_data{_transformer_short_name} = $transformer_short_name; | |||||||||||||||||||||||||||
| 29 | $non_public_data{_profile_strictness} = | ||||||||||||||||||||||||||||
| 30 | 2771 | $self{$NON_PUBLIC_DATA}{_profile_strictness}; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2771 | foreach my $standard_parameter ( | |||||||||||||||||||||||||||
| 33 | qw< necessity set_themes add_themes > | ||||||||||||||||||||||||||||
| 34 | ) { | ||||||||||||||||||||||||||||
| 35 | 8313 | ▶ | if ( exists $self{$standard_parameter} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | $non_public_data{"_$standard_parameter"} = | ||||||||||||||||||||||||||||
| 37 | 127 | delete $self{$standard_parameter}; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 2771 | $self{$NON_PUBLIC_DATA} = \%non_public_data; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 2771 | return bless \%self, $class; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 3896 | ▶ | sub _get_non_public_data { | ||||||||||||||||||||||||||
|
Subroutine
_get_non_public_data: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | 3896 | my $self = shift; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 3896 | return $self->{$NON_PUBLIC_DATA}; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 4 | ▶ | sub get_transformer_short_name { | ||||||||||||||||||||||||||
|
Subroutine
get_transformer_short_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 4 | return $self->_get_non_public_data()->{_transformer_short_name}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1297 | ▶ | sub get_set_themes { | ||||||||||||||||||||||||||
|
Subroutine
get_set_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 1297 | my ($self) = @_; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1297 | return $self->_get_non_public_data()->{_set_themes}; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1297 | ▶ | sub get_add_themes { | ||||||||||||||||||||||||||
|
Subroutine
get_add_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 1297 | my ($self) = @_; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1297 | return $self->_get_non_public_data()->{_add_themes}; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1298 | ▶ | sub get_necessity { | ||||||||||||||||||||||||||
|
Subroutine
get_necessity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 1298 | my ($self) = @_; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1298 | return $self->_get_non_public_data()->{_necessity}; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 9 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 9 | my ($self, $parameter) = @_; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 9 | ▶ | return if $parameter eq $NON_PUBLIC_DATA; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 7 | return $self->{$parameter}; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 38 | ▶ | sub remove { | ||||||||||||||||||||||||||
|
Subroutine
remove: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 100 | 38 | my ($self, $parameter) = @_; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 38 | ▶ | return if $parameter eq $NON_PUBLIC_DATA; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 38 | delete $self->{$parameter}; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 38 | return; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 3 | ▶ | sub is_empty { | ||||||||||||||||||||||||||
|
Subroutine
is_empty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 3 | return 1 >= keys %{$self}; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 1377 | ▶ | sub get_parameter_names { | ||||||||||||||||||||||||||
|
Subroutine
get_parameter_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 1377 | my ($self) = @_; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 1377 | return grep { $_ ne $NON_PUBLIC_DATA } keys %{$self}; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 1374 | ▶ | sub handle_extra_parameters { | ||||||||||||||||||||||||||
|
Subroutine
handle_extra_parameters: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | 1374 | my ($self, $transformer, $errors) = @_; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 1374 | my $profile_strictness = $self->{$NON_PUBLIC_DATA}{_profile_strictness}; | |||||||||||||||||||||||||||
| 131 | 1374 | ▶ | defined $profile_strictness | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | or $profile_strictness = $PROFILE_STRICTNESS_DEFAULT; | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 1374 | ▶ | return if $profile_strictness eq $PROFILE_STRICTNESS_QUIET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 1374 | ▶ | my $parameter_errors = $profile_strictness eq $PROFILE_STRICTNESS_WARN ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | Perl::ToPerl6::Exception::AggregateConfiguration->new() : $errors; | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 1374 | foreach my $offered_param ( $self->get_parameter_names() ) { | |||||||||||||||||||||||||||
| 140 | 40 | $parameter_errors->add_exception( | |||||||||||||||||||||||||||
| 141 | Perl::ToPerl6::Exception::Configuration::Option::Transformer::ExtraParameter->new( | ||||||||||||||||||||||||||||
| 142 | transformer => $transformer->get_short_name(), | ||||||||||||||||||||||||||||
| 143 | option_name => $offered_param, | ||||||||||||||||||||||||||||
| 144 | source => undef, | ||||||||||||||||||||||||||||
| 145 | ) | ||||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 1374 | ▶ | warn qq<$parameter_errors\n> | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$profile_strictness eq $Perl::ToPerl6::TransformerConfig::PROFILE_STRICTNESS_WARN and $parameter_errors->has_exceptions
MC/DC100%2/2
$profile_strictness eq $Perl::ToPerl6::TransformerConfig::PROFILE_STRICTNESS_WARN and $parameter_errors->has_exceptions
$profile_strictness eq $Perl::ToPerl6::TransformerConfig::PROFILE_STRICTNESS_WARN
$parameter_errors->has_exceptions
Truth table100%3/3
A and B
A= $profile_strictness eq $Perl::ToPerl6::TransformerConfig::PROFILE_STRICTNESS_WARNB= $parameter_errors->has_exceptions
| |||||||||||||||||||||||||||||
| 150 | if ($profile_strictness eq $PROFILE_STRICTNESS_WARN | ||||||||||||||||||||||||||||
| 151 | && $parameter_errors->has_exceptions()); | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 1374 | return; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 1336 | ▶ | sub set_profile_strictness { | ||||||||||||||||||||||||||
|
Subroutine
set_profile_strictness: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 159 | 1336 | my ($self, $profile_strictness) = @_; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 1336 | $self->{$NON_PUBLIC_DATA}{_profile_strictness} = $profile_strictness; | |||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 1336 | return; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 25 | 1; | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | __END__ | ||||||||||||||||||||||||||||