MaxMind/DB/Metadata.pm

filter: Statementstmt 53.8% 28 / 52 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 55.5% 35 / 63 CC 3 SCAR 10.4
CC
3
Cov
54%
metadata_to_encode
6.0
debug_dump
6.0
BEGIN
1.0
CRAP 2.8
« MaxMind/DB/Role/Debugs.pm ↑ Summary Test/MaxMind/DB/Common/Data.pm »
1 package MaxMind::DB::Metadata;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.040001';
8  
9 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use MaxMind::DB::Types qw( ArrayRefOfStr Epoch HashRefOfStr Int Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use MooX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 with 'MaxMind::DB::Role::Debugs';
14  
15 {
16 2 my %metadata = (
17 binary_format_major_version => Int,
18 binary_format_minor_version => Int,
19 build_epoch => Epoch,
20 database_type => Str,
21 description => HashRefOfStr,
22 ip_version => Int,
23 node_count => Int,
24 record_size => Int,
25 );
26  
27 2 for my $attr ( keys %metadata ) {
28 has $attr => (
29 is => 'ro',
30 16 isa => $metadata{$attr},
31 required => 1,
32 );
33 }
34 }
35  
36 has languages => (
37 is => 'ro',
38 isa => ArrayRefOfStr,
39 2 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
40 2 );
41  
42 0 ▶sub metadata_to_encode {
Subroutine metadata_to_encode: not called CC=2 SCAR=17.9
Pod undocumented
43 0 my $self = shift;
44  
45 0 my %metadata;
46 0 foreach my $attr ( $self->meta()->get_all_attributes() ) {
47 0 my $method = $attr->name;
48 0 $metadata{$method} = $self->$method;
49 }
50  
51 0 return \%metadata;
52 }
53  
54 0 ▶sub debug_dump {
Subroutine debug_dump: not called CC=2 SCAR=17.9
Pod undocumented
55 0 my $self = shift;
56  
57 0 $self->_debug_newline();
58  
59 0 $self->_debug_message('Metadata:');
60 0 my $version = join '.',
61 $self->binary_format_major_version(),
62 $self->binary_format_minor_version();
63 0 $self->_debug_string( ' Binary format version', $version );
64  
65 0 require DateTime;
66 0 $self->_debug_string(
67 ' Build epoch',
68 $self->build_epoch() . ' ('
69 . DateTime->from_epoch( epoch => $self->build_epoch() ) . ')'
70 );
71  
72 0 $self->_debug_string( ' Database type', $self->database_type() );
73  
74 0 my $description = $self->description();
75 0 for my $locale ( sort keys %{$description} ) {
76 $self->_debug_string(
77 " Description [$locale]",
78 0 $description->{$locale}
79 );
80 }
81  
82 0 $self->_debug_string( ' IP version', $self->ip_version() );
83 0 $self->_debug_string( ' Node count', $self->node_count() );
84 0 $self->_debug_string( ' Record size (in bits)', $self->record_size() );
85 $self->_debug_string(
86 ' Languages', join ', ',
87 0 @{ $self->languages() }
88 );
89  
90 0 return;
91 }
92  
93 2 __PACKAGE__->meta()->make_immutable();
94  
95 2 1;
96  
97 #ABSTRACT: A class for metadata related to a MaxMind DB database
98  
99 __END__
« MaxMind/DB/Role/Debugs.pm ↑ Summary Test/MaxMind/DB/Common/Data.pm »