line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Metadata; |
2
|
|
|
|
|
|
|
$MaxMind::DB::Metadata::VERSION = '0.031003'; |
3
|
2
|
|
|
2
|
|
26881
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
73
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
5
|
2
|
|
|
2
|
|
8068
|
use namespace::autoclean; |
|
2
|
|
|
|
|
81622
|
|
|
2
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
2230
|
use Math::Int128; |
|
2
|
|
|
|
|
31463
|
|
|
2
|
|
|
|
|
126
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
3291
|
use Moo; |
|
2
|
|
|
|
|
41645
|
|
|
2
|
|
|
|
|
24
|
|
10
|
2
|
|
|
2
|
|
9749
|
use MaxMind::DB::Types qw( ArrayRefOfStr Epoch HashRefOfStr Int Str ); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
237
|
|
11
|
2
|
|
|
2
|
|
16276
|
use MooX::StrictConstructor; |
|
2
|
|
|
|
|
33789
|
|
|
2
|
|
|
|
|
18
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'MaxMind::DB::Role::Debugs'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
for my $attr ( keys %metadata ) { |
28
|
|
|
|
|
|
|
has $attr => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => $metadata{$attr}, |
31
|
|
|
|
|
|
|
required => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has languages => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => ArrayRefOfStr, |
39
|
|
|
|
|
|
|
default => sub { [] }, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub metadata_to_encode { |
43
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub debug_dump { |
55
|
0
|
|
|
0
|
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} ) { |
|
0
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$self->_debug_string( |
77
|
|
|
|
|
|
|
" Description [$locale]", |
78
|
|
|
|
|
|
|
$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
|
0
|
|
|
|
|
|
$self->_debug_string( |
86
|
|
|
|
|
|
|
' Languages', join ', ', |
87
|
0
|
|
|
|
|
|
@{ $self->languages() } |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#ABSTRACT: A class for metadata related to a MaxMind DB database |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=pod |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
MaxMind::DB::Metadata - A class for metadata related to a MaxMind DB database |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 VERSION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
version 0.031003 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SYNOPSIS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $reader = MaxMind::DB::Reader->new( file => $path ); |
114
|
|
|
|
|
|
|
my $metadata = $reader->metadata(); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
print $metadata->description()->{en}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This class provides an API for representing the metadata of a MaxMind DB |
121
|
|
|
|
|
|
|
database. See http://maxmind.github.io/MaxMind-DB/ for the official format |
122
|
|
|
|
|
|
|
spec. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 API |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This class provides methods for each metadata attribute in a database. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 $metadata->binary_format_major_version() |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns the binary format major version number. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 $metadata->binary_format_minor_version() |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns the binary format minor version number. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 $metadata->build_epoch() |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns the database's build timestamp as an epoch value. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 $metadata->database_type() |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Returns a string indicating the database's type. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 $metadata->languages() |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Returns an arrayref of locale codes indicating what languages this database |
147
|
|
|
|
|
|
|
has information for. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 $metadata->description() |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns a hashref of descriptions. The keys should be locale codes like "en" |
152
|
|
|
|
|
|
|
or "pt-BR" and the values are the description in that language. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 $metadata->ip_version() |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Returns a 4 or 6 indicating what type of IP addresses this database can be |
157
|
|
|
|
|
|
|
used to look up. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 $metadata->node_count() |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Returns the number of nodes in the database's search tree. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 $metadata->record_size() |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Returns the record size for nodes in the database's search tree. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHORS |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=over 4 |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Dave Rolsky <drolsky@maxmind.com> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Olaf Alders <oalders@maxmind.com> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by MaxMind, Inc.. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This is free software, licensed under: |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |