| 1 | package Hades::Myths; | ||||||||||||||||||||||||||||
| 2 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use POSIX qw/locale_h/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 14 | our $VERSION = 0.21; | |||||||||||||||||||||||||||
| 6 | 14 | our ($STASH); | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | sub new { | ||||||||||||||||||||||||||||
| 9 | 4 | ▶ | my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ ); | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=29.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | 4 | my $self = bless {}, $cls; | |||||||||||||||||||||||||||
| 11 | 4 | my %accessors = (); | |||||||||||||||||||||||||||
| 12 | 4 | for my $accessor ( keys %accessors ) { | |||||||||||||||||||||||||||
| 13 | my $param | ||||||||||||||||||||||||||||
| 14 | = defined $args{$accessor} | ||||||||||||||||||||||||||||
| 15 | ? $args{$accessor} | ||||||||||||||||||||||||||||
| 16 | 0 | ▶ | : $accessors{$accessor}->{default}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | my $value | ||||||||||||||||||||||||||||
| 18 | = $self->$accessor( $accessors{$accessor}->{builder} | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | ? $accessors{$accessor}->{builder}->( $self, $param ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | : $param ); | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | unless ( !$accessors{$accessor}->{required} || defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $accessors{$accessor}{"required"} or defined $value
MC/DC0%0/2
not $accessors{$accessor}{"required"} or defined $value
not $accessors{$accessor}{"required"}
defined $value
Truth table0%0/3
not(A) or B
A= not $accessors{$accessor}{"required"}B= defined $value
| |||||||||||||||||||||||||||||
| 22 | 0 | die "$accessor accessor is required"; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | 4 | return $self; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub import { | ||||||||||||||||||||||||||||
| 29 | 16 | ▶ | my ( $self, $locales, @additional ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=14 SCAR=27.2
| |||||||||||||||||||||||||||||
| 30 | 16 | ▶ | if ( defined $locales ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 15 | ▶ | if ( ( ref($locales) || "" ) ne "HASH" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
ref $locales || ''
MC/DC100%1/1
ref $locales || ''
ref $locales
Truth table100%2/2
A
A= ref $locales
| |||||||||||||||||||||||||||||
| 32 | 2 | die | |||||||||||||||||||||||||||
| 33 | qq{Optional[HashRef]: invalid value $locales for variable \$locales in method import}; | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 14 | my $caller = caller(); | |||||||||||||||||||||||||||
| 37 | 14 | ▶ | $STASH = delete $locales->{stash} || 'Hades::Myths::Object'; | ||||||||||||||||||||||||||
|
Condition50%1/2
delete $locales->{'stash'} || 'Hades::Myths::Object'
MC/DC0%0/1
delete $locales->{'stash'} || 'Hades::Myths::Object'
delete $locales->{'stash'}
Truth table50%1/2
A
A= delete $locales->{'stash'}
| |||||||||||||||||||||||||||||
| 38 | 14 | eval "require $STASH"; | |||||||||||||||||||||||||||
| 39 | my ( $locale, $lang, $fb ) = $STASH->convert_locale( | ||||||||||||||||||||||||||||
| 40 | delete $locales->{locale} || setlocale(LC_CTYPE), | ||||||||||||||||||||||||||||
| 41 | , delete $locales->{fb}, | ||||||||||||||||||||||||||||
| 42 | 14 | ▶ | ); | ||||||||||||||||||||||||||
|
Condition33%1/3
delete $locales->{'locale'} || setlocale(0)
MC/DC0%0/2
delete $locales->{'locale'} || setlocale(0)
delete $locales->{'locale'}
setlocale(0)
Truth table33%1/3
A || B
A= delete $locales->{'locale'}B= setlocale(0)
| |||||||||||||||||||||||||||||
| 43 | 14 | my $as_keyword = delete $locales->{as_keywords}; | |||||||||||||||||||||||||||
| 44 | 14 | ▶ | $locales = undef if ( !ref $locales || !scalar keys %{$locales} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $locales and scalar keys %{$locales;}
MC/DC0%0/2
ref $locales and scalar keys %{$locales;}
ref $locales
scalar keys %{$locales;}
Truth table33%1/3
A and B
A= ref $localesB= scalar keys %{$locales;}
| |||||||||||||||||||||||||||||
| 45 | 14 | ▶ | my ($new) = $STASH->new( | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 46 | ( defined $fb ? ( fb => $fb ) : () ), | ||||||||||||||||||||||||||||
| 47 | ( defined $lang ? ( language => $lang ) : () ), | ||||||||||||||||||||||||||||
| 48 | ( defined $locale ? ( locale => $locale ) : () ), | ||||||||||||||||||||||||||||
| 49 | ( defined $locales ? ( locales => $locales ) : () ), | ||||||||||||||||||||||||||||
| 50 | @additional | ||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||
| 53 | 14 | ▶ | no strict "refs"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | 14 | ▶ | no warnings "redefine"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 14 | ▶ | *{"${caller}::locales"} = sub {$new}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||
| 56 | 14 | ▶ | if ($as_keyword) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 13 | for my $key ( keys %{ $new->locales } ) { | |||||||||||||||||||||||||||
| 58 | 14 | ▶ | no strict "refs"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 14 | ▶ | no warnings "redefine"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 650 | ▶ | *{"${caller}::${key}"} = sub { $new->string( $key, @_ ); }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | sub new_object { | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my ( $self, %object ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new_object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | return $STASH->new(%object); | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 14 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head1 NAME | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Hades::Myths - error handling for hades. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head1 VERSION | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Version 0.01 | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | use Hades::Myths; | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | say stranger; | ||||||||||||||||||||||||||||
| 92 | die locales->stranger; | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head2 new | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | Instantiate a new Hades::Myths object. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Hades::Myths->new | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head2 import | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | call import method. Expects param $locales to be a Optional[HashRef], param @additional to be any value including undef. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | $obj->import($locales, @additional) | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head2 new_object | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | Accepts a list of arguments that are used to build a new Hades::Myths::Object. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | Hades::Myths::Object->new_object( | ||||||||||||||||||||||||||||
| 114 | locale => $locale, | ||||||||||||||||||||||||||||
| 115 | locales => { | ||||||||||||||||||||||||||||
| 116 | %locales | ||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | LNATION, C<< <email at lnation.org> >> | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head1 BUGS | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | Please report any bugs or feature requests to C<bug-hades::myths at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 128 | the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Myths>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 129 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | perldoc Hades::Myths | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | You can also look for information at: | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =over 4 | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Myths> | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | L<http://annocpan.org/dist/Hades-Myths> | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | L<https://cpanratings.perl.org/d/Hades-Myths> | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | L<https://metacpan.org/release/Hades-Myths> | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =back | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | This software is Copyright (c) 2020 by LNATION. | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | This is free software, licensed under: | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||