blib/lib/Hades/Realm/Import/Export.pm

filter: Statementstmt 94.2% 49 / 52 Branchbran 64.2% 18 / 28 Conditioncond 71.4% 10 / 14 MC/DCmcdc 62.5% 5 / 8 Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 82.3% 93 / 113 CC 24 SCAR 23.8
CC
24
Cov
82%
build_exporter
15.2
new
12.2
after_class
4.0
CRAP 10.8
↑ Summary
1 package Hades::Realm::Import::Export;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use base qw/Hades::Realm::Exporter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 our $VERSION = 0.02;
6  
7 sub new {
8 8 ▶ my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ );
Subroutine new: called CC=6 SCAR=25.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ == 1 ? : 7 1 8
9 8 my $self = $cls->SUPER::new(%args);
10 8 my %accessors = ();
11 8 for my $accessor ( keys %accessors ) {
12 my $value
13 = $self->$accessor(
14 defined $args{$accessor}
15 ? $args{$accessor}
16 0 ▶ : $accessors{$accessor}->{default} );
Branch: 1 branch
BranchTrueFalseTotal
defined $args{$accessor} ? : 0 0 0
17 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
18 0 die "$accessor accessor is required";
19 }
20 }
21 8 return $self;
22 }
23  
24 sub build_new {
25 4 ▶ my ( $orig, $self, @params ) = ( 'SUPER::build_new', @_ );
Subroutine build_new: called CC=2 SCAR=7.1
Pod documented
26  
27 4 my @res = $self->$orig( @params, q|%EX| );
28  
29 4 ▶ return wantarray ? @res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 4 4
30 }
31  
32 sub build_exporter {
33 12 ▶ my ( $self, $begin, $mg, $export, $meta ) = @_;
Subroutine build_exporter: called CC=15 SCAR=27.2
Pod documented
34 12 ▶ if ( !defined($begin) || ref $begin ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $begin or ref $begin) 2 10 12
Condition66%2/3
not defined $begin or ref $begin
l!l&&r!l&&!r
0210
MC/DC50%1/2
not defined $begin or ref $begin
not defined $begin ref $begin
Truth table66%2/3
not(A) or B
A= not defined $beginB= ref $begin
ABresult
1X1
011
000
35 2 ▶ $begin = defined $begin ? $begin : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $begin ? : 2 0 2
36 2 die
37 qq{Str: invalid value $begin for variable \$begin in method build_exporter};
38 }
39 10 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 8 10
Condition100%2/2
ref $mg || ''
l!l
91
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
40 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
41 2 die
42 qq{Object: invalid value $mg for variable \$mg in method build_exporter};
43 }
44 8 ▶ if ( ( ref($export) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $export || "") ne "HASH") 2 6 8
Condition100%2/2
ref $export || ''
l!l
71
MC/DC100%1/1
ref $export || ''
ref $export
Truth table100%2/2
A
A= ref $export
Aresult
11
00
45 2 ▶ $export = defined $export ? $export : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $export ? : 2 0 2
46 2 die
47 qq{HashRef: invalid value $export for variable \$export in method build_exporter};
48 }
49 6 ▶ if ( ( ref($meta) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $meta || "") ne "HASH") 2 4 6
Condition100%2/2
ref $meta || ''
l!l
51
MC/DC100%1/1
ref $meta || ''
ref $meta
Truth table100%2/2
A
A= ref $meta
Aresult
11
00
50 2 ▶ $meta = defined $meta ? $meta : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $meta ? : 2 0 2
51 2 die
52 qq{HashRef: invalid value $meta for variable \$meta in method build_exporter};
53 }
54  
55 4 my %ex = ();
56 4 for my $k ( keys %{$export} ) {
57 22 push @{ $ex{$_} }, $k for ( @{ $export->{$k} } );
58 }
59 4 my $ex_tags = Module::Generate::_stringify_struct( 'undefined', \%ex );
60 4 $ex_tags =~ s/^{/(/;
61 4 $ex_tags =~ s/}$/);/;
62 4 $begin = '%EX = ' . $ex_tags . $begin;
63 4 return $begin;
64  
65 }
66  
67 sub after_class {
68 6 ▶ my ( $self, $mg ) = @_;
Subroutine after_class: called CC=4 SCAR=13.9
Pod documented
69 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
70 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
71 2 die
72 qq{Object: invalid value $mg for variable \$mg in method after_class};
73 }
74  
75 4 $mg->base(q|Import::Export|);
76  
77 }
78  
79 5 1;
80  
81 __END__
82  
83 =head1 NAME
84  
85 Hades::Realm::Import::Export - Hades realm for Import::Export
86  
87 =head1 VERSION
88  
89 Version 0.01
90  
91 =cut
92  
93 =head1 SYNOPSIS
94  
95 Quick summary of what the module does:
96  
97 Hades->run({
98 eval => 'Kosmos {
99 [curae penthos] :t(Int) :d(2) :p :pr :c :r :i(1, GROUP)
100 geras $nosoi :t(Int) :d(5) :i { if (penthos() == $nosoi) { return curae; } }
101 }',
102 realm => 'Import::Export',
103 });
104  
105 ... generates ...
106  
107 package Kosmos;
108 use strict;
109 use warnings;
110 use base qw/Import::Export/;
111 our $VERSION = 0.01;
112 our ( %EX, %ACCESSORS );
113  
114 BEGIN {
115 %EX = (
116 'curae' => [ 'EXPORT', 'EXPORT_OK', 'ACCESSORS', 'GROUP' ],
117 'clear_penthos' => [ 'EXPORT', 'EXPORT_OK', 'CLEARERS' ],
118 'penthos' => [ 'EXPORT', 'EXPORT_OK', 'ACCESSORS', 'GROUP' ],
119 'geras' => [ 'EXPORT_OK', 'METHODS' ],
120 'has_curae' => [ 'EXPORT', 'EXPORT_OK', 'PREDICATES' ],
121 'has_penthos' => [ 'EXPORT', 'EXPORT_OK', 'PREDICATES' ],
122 'clear_curae' => [ 'EXPORT', 'EXPORT_OK', 'CLEARERS' ]
123 );
124 %ACCESSORS = ( curae => 2, penthos => 2, );
125 }
126  
127 sub curae {
128 my ($value) = @_;
129 my $private_caller = caller();
130 if ( $private_caller ne __PACKAGE__ ) {
131 die "cannot call private method curae from $private_caller";
132 }
133 if ( defined $value ) {
134 if ( ref $value || $value !~ m/^[-+\d]\d*$/ ) {
135 die qq{Int: invalid value $value for accessor curae};
136 }
137 $ACCESSORS{curae} = $value;
138 }
139 return $ACCESSORS{curae};
140 }
141  
142 sub has_curae {
143 return exists $ACCESSORS{curae};
144 }
145  
146 sub clear_curae {
147 delete $ACCESSORS{curae};
148 return 1;
149 }
150  
151 sub penthos {
152 my ($value) = @_;
153 my $private_caller = caller();
154 if ( $private_caller ne __PACKAGE__ ) {
155 die "cannot call private method penthos from $private_caller";
156 }
157 if ( defined $value ) {
158 if ( ref $value || $value !~ m/^[-+\d]\d*$/ ) {
159 die qq{Int: invalid value $value for accessor penthos};
160 }
161 $ACCESSORS{penthos} = $value;
162 }
163 return $ACCESSORS{penthos};
164 }
165  
166 sub has_penthos {
167 return exists $ACCESSORS{penthos};
168 }
169  
170 sub clear_penthos {
171 delete $ACCESSORS{penthos};
172 return 1;
173 }
174  
175 sub geras {
176 my ($nosoi) = @_;
177 $nosoi = defined $nosoi ? $nosoi : 5;
178 if ( !defined($nosoi) || ref $nosoi || $nosoi !~ m/^[-+\d]\d*$/ ) {
179 $nosoi = defined $nosoi ? $nosoi : 'undef';
180 die
181 qq{Int: invalid value $nosoi for variable \$nosoi in method geras};
182 }
183 if ( penthos() == $nosoi ) { return curae(); }
184 }
185  
186 1;
187  
188 __END__
189  
190 =head1 SUBROUTINES/METHODS
191  
192 =head2 new
193  
194 Instantiate a new Hades::Realm::Import::Export object.
195  
196 Hades::Realm::Import::Export->new
197  
198 =head2 build_new
199  
200 call build_new method.
201  
202 =head2 build_exporter
203  
204 call build_exporter method. Expects param $begin to be a Str, param $mg to be a Object, param $export to be a HashRef, param $meta to be a HashRef.
205  
206 $obj->build_exporter($begin, $mg, $export, $meta)
207  
208 =head2 after_class
209  
210 call after_class method. Expects param $mg to be a Object.
211  
212 $obj->after_class($mg)
213  
214 =head1 AUTHOR
215  
216 LNATION, C<< <email at lnation.org> >>
217  
218 =head1 BUGS
219  
220 Please report any bugs or feature requests to C<bug-hades::realm::import::export at rt.cpan.org>, or through
221 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Realm-Import-Export>. I will be notified, and then you'll
222 automatically be notified of progress on your bug as I make changes.
223  
224 =head1 SUPPORT
225  
226 You can find documentation for this module with the perldoc command.
227  
228 perldoc Hades::Realm::Import::Export
229  
230 You can also look for information at:
231  
232 =over 4
233  
234 =item * RT: CPAN's request tracker (report bugs here)
235  
236 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Realm-Import-Export>
237  
238 =item * AnnoCPAN: Annotated CPAN documentation
239  
240 L<http://annocpan.org/dist/Hades-Realm-Import-Export>
241  
242 =item * CPAN Ratings
243  
244 L<https://cpanratings.perl.org/d/Hades-Realm-Import-Export>
245  
246 =item * Search CPAN
247  
248 L<https://metacpan.org/release/Hades-Realm-Import-Export>
249  
250 =back
251  
252 =head1 ACKNOWLEDGEMENTS
253  
254 =head1 LICENSE AND COPYRIGHT
255  
256 This software is Copyright (c) 2020 by LNATION.
257  
258 This is free software, licensed under:
259  
260 The Artistic License 2.0 (GPL Compatible)
261  
262 =cut
263  
264
↑ Summary