| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::IATA; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
51987
|
use warnings; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
118
|
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
106
|
|
|
5
|
3
|
|
|
3
|
|
19
|
use Carp; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
290
|
|
|
6
|
3
|
|
|
3
|
|
18
|
use File::Spec; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
94
|
|
|
7
|
3
|
|
|
3
|
|
9780
|
use DBI; |
|
|
3
|
|
|
|
|
97122
|
|
|
|
3
|
|
|
|
|
286
|
|
|
8
|
3
|
|
|
3
|
|
4017
|
use Sub::Install qw(install_sub); |
|
|
3
|
|
|
|
|
20427
|
|
|
|
3
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
10785
|
use version; |
|
|
3
|
|
|
|
|
9376
|
|
|
|
3
|
|
|
|
|
22
|
|
|
11
|
3
|
|
|
3
|
|
529
|
use vars '$VERSION'; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
963
|
|
|
12
|
|
|
|
|
|
|
$VERSION = qv('0.0.3'); |
|
13
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
|
16
|
2
|
|
|
2
|
1
|
913
|
my $self = shift; |
|
17
|
2
|
|
33
|
|
|
20
|
my $pkg = ref $self || $self; |
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
5
|
my $path = shift; |
|
20
|
2
|
50
|
|
|
|
9
|
unless ($path){ |
|
21
|
0
|
|
|
|
|
0
|
my $db = $pkg; |
|
22
|
0
|
|
|
|
|
0
|
$db =~s{::}{/}gxms; |
|
23
|
0
|
|
|
|
|
0
|
$db =~s{$}{.pm}xms; |
|
24
|
0
|
|
|
|
|
0
|
($path = $INC{$db}) =~ s{.pm$}{}xms; |
|
25
|
0
|
|
|
|
|
0
|
$path="iata_sqlite.db"; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
|
28
|
2
|
|
|
|
|
29
|
my $dbh = DBI->connect("dbi:SQLite:dbname=$path","","", {RaiseError => 1, unicode=> 1}); |
|
29
|
2
|
|
|
|
|
28269
|
return bless {dbh => $dbh, dbname => $path}, $pkg; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub AUTOLOAD { ## no critic qw(ClassHierarchies::ProhibitAutoloading Subroutines::RequireArgUnpacking) |
|
33
|
9
|
|
|
9
|
|
1100
|
my $func = $AUTOLOAD; |
|
34
|
9
|
|
|
|
|
77
|
$func =~ s/.*:://xms; |
|
35
|
|
|
|
|
|
|
|
|
36
|
9
|
100
|
|
|
|
26
|
if ( grep { $func eq $_ } qw( iata icao airport location ) ) { |
|
|
36
|
50
|
|
|
|
133
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
3
|
|
|
3
|
|
22
|
no strict 'refs'; ## no critic 'TestingAndDebugging::ProhibitNoStrict' |
|
|
3
|
|
|
|
|
12
|
|
|
|
3
|
|
|
|
|
1433
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
install_sub( |
|
41
|
|
|
|
|
|
|
{ code => sub { |
|
42
|
7
|
|
|
7
|
|
14
|
my $self = shift; |
|
43
|
7
|
|
|
|
|
15
|
my $arg = shift; |
|
44
|
7
|
|
|
|
|
24
|
my $sth = $self->dbh->prepare("select * from iata where $func like ?"); |
|
45
|
7
|
|
|
|
|
19184
|
$sth->execute($arg); |
|
46
|
7
|
|
|
|
|
185
|
my $result = $sth->fetchall_arrayref( {} ); |
|
47
|
7
|
|
|
|
|
4218
|
$sth->finish; |
|
48
|
7
|
|
|
|
|
234
|
return $result; |
|
49
|
|
|
|
|
|
|
}, |
|
50
|
3
|
|
|
|
|
36
|
into => ref $_[0], |
|
51
|
|
|
|
|
|
|
as => $func, |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
); |
|
54
|
3
|
|
|
|
|
169
|
goto &$func; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
elsif ( $func =~ m/^(iata|icao|airport|location)2(iata|icao|airport|location)$/xms ) { |
|
57
|
6
|
|
|
|
|
21
|
my $from = $1; |
|
58
|
6
|
|
|
|
|
14
|
my $to = $2; |
|
59
|
3
|
|
|
3
|
|
37
|
no strict 'refs'; ## no critic 'TestingAndDebugging::ProhibitNoStrict' |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
846
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
install_sub( |
|
62
|
|
|
|
|
|
|
{ code => sub { |
|
63
|
6
|
|
|
6
|
|
14
|
my $self = shift; |
|
64
|
6
|
|
|
|
|
8
|
my $arg = shift; |
|
65
|
6
|
|
|
|
|
32
|
return $self->$from($arg)->[0]{$to}; |
|
66
|
|
|
|
|
|
|
}, |
|
67
|
6
|
|
|
|
|
92
|
into => ref $_[0], |
|
68
|
|
|
|
|
|
|
as => $func, |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
); |
|
71
|
6
|
|
|
|
|
469
|
goto &$func; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
else { |
|
74
|
0
|
|
|
|
|
0
|
croak "unknown subroutine $func"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
0
|
return; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub DESTROY { |
|
80
|
2
|
|
|
2
|
|
1440
|
my $self = shift; |
|
81
|
2
|
|
|
|
|
11
|
my $dbh = $self->dbh; |
|
82
|
2
|
50
|
|
|
|
22
|
if ($dbh){ |
|
83
|
2
|
|
|
|
|
368
|
$dbh->disconnect; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
2
|
|
|
|
|
5
|
undef $self; |
|
86
|
2
|
|
|
|
|
434
|
return; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub dbh { |
|
90
|
9
|
|
|
9
|
1
|
127
|
return shift->{dbh}; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
94
|
|
|
|
|
|
|
__END__ |