Grid/Types.pm

filter: Statementstmt 80.8% 38 / 47 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 61.5% 8 / 13 Podpod n/a totaltotal 68.6% 46 / 67 CC 3 SCAR 11.8
CC
3
Cov
73%
__ANON__
12.0
__ANON__
1.4
__ANON__
1.1
CRAP 3.3
« Grid/Excel.pm ↑ Summary Grid/Cell.pm »
1 package Data::Grid::Types;
2  
3 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Type::Library -base, -declare => qw(FHlike Source Fields HeaderFlags
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 Offsets Checker);
9 1 ▶use Type::Utils -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Types::Standard qw(Maybe Any Value Bool Str Int ScalarRef ArrayRef
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 GlobRef Enum Object InstanceOf);
12 1 ▶use Types::XSD::Lite qw(NonNegativeInteger);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # not sure if this is smart or stupid
15 1 ▶use Class::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 our $VERSION = '0.02_01';
18  
19 =head1 NAME
20  
21 Data::Grid::Types - Type library for Data::Grid
22  
23 =head1 TYPES
24  
25 So far these are only used in L<Data::Grid/parse> and nowhere else.
26  
27 =head2 FHlike
28  
29 Either a filehandle or an instance of L<IO::Seekable>.
30  
31 =cut
32  
33 1 subtype FHlike, as GlobRef|InstanceOf['IO::Seekable'];
34  
35 =head2 Source
36  
37 Anything that can be recognized as a data source.
38  
39 =cut
40  
41 1 subtype Source, as Str|FHlike|ScalarRef[Value]|ArrayRef[Maybe[Value|Object]];
42  
43 =head2 Fields
44  
45 An array reference of array references of strings to for row hash
46 constructors for each table. Will coerce from a single array.
47  
48 =cut
49  
50 1 subtype Fields, as ArrayRef[ArrayRef[Str]];
51 0 ▶coerce Fields, from ArrayRef[Value|Object], via { [$_] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
52  
53 =head2 HeaderFlags
54  
55 Similar idea, except for the flag that notifies of the existence of a
56 header. Coerces from a single value.
57  
58 =cut
59  
60 1 subtype HeaderFlags, as ArrayRef[Bool];
61 0 ▶coerce HeaderFlags, from ArrayRef[Any], via { [map { !!$_ } @{$_}] };
Subroutine __ANON__: not called CC=1 SCAR=3.5
62 0 ▶coerce HeaderFlags, from Maybe[Value], via { [!!$_] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
63  
64 =head2 Offsets
65  
66 This is an array of offsets, which are non-negative integers.
67  
68 =cut
69  
70 1 subtype Offsets, as ArrayRef[NonNegativeInteger];
71 0 ▶coerce Offsets, from NonNegativeInteger, via { [$_] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
72  
73 =head2 Checker
74  
75 =cut
76  
77 1 my %CMAP = (
78 'MMagic' => 'File::MMagic',
79 'MimeInfo' => 'File::MimeInfo::Magic',
80 );
81  
82 1 my @ENUM = qw(MMagic MimeInfo File::MMagic File::MimeInfo::Magic);
83  
84 1 subtype Checker, as InstanceOf['File::MMagic', 'File::MimeInfo::Magic'];
85 0 ▶coerce Checker, from Enum[@ENUM], via {
Subroutine __ANON__: not called CC=3 SCAR=24.8
86 0 ▶ my $class = $CMAP{$_} || $_;
Condition0%0/3
$CMAP{$_} || $_
l!l&&r!l&&!r
000
MC/DC0%0/2
$CMAP{$_} || $_
$CMAP{$_} $_
Truth table0%0/3
A || B
A= $CMAP{$_}B= $_
ABresult
1X1
011
000
87  
88 0 ▶ Class::Load::try_load_class($class) or die
Branch: 1 branch
BranchTrueFalseTotal
Class::Load::try_load_class($class) or die "Install $class to do type detection. See docs." 0 0 0
89 "Install $class to do type detection. See docs.";
90  
91 0 $class->new;
92 1 };
93  
94 =head1 COPYRIGHT & LICENSE
95  
96 Copyright 2010-2018 Dorian Taylor.
97  
98 Licensed under the Apache License, Version 2.0 (the "License"); you
99 may not use this file except in compliance with the License. You may
100 obtain a copy of the License at
101 L<http://www.apache.org/licenses/LICENSE-2.0>.
102  
103 Unless required by applicable law or agreed to in writing, software
104 distributed under the License is distributed on an "AS IS" BASIS,
105 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
106 implied. See the License for the specific language governing
107 permissions and limitations under the License.
108  
109 =cut
110  
111 1 1;
« Grid/Excel.pm ↑ Summary Grid/Cell.pm »