Hades/Myths.pm

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