line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Data::Phrasebook::Loader::JSON::Syck; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
157219
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
142
|
|
5
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
203
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
18
|
use Carp 'croak'; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
492
|
|
8
|
3
|
|
|
3
|
|
4300
|
use JSON::Syck (); |
|
3
|
|
|
|
|
17700
|
|
|
3
|
|
|
|
|
68
|
|
9
|
3
|
|
|
3
|
|
43494
|
use File::Slurp (); |
|
3
|
|
|
|
|
96479
|
|
|
3
|
|
|
|
|
163
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
2600
|
use Data::Phrasebook; |
|
3
|
|
|
|
|
6588
|
|
|
3
|
|
|
|
|
152
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
23
|
use base 'Data::Phrasebook::Loader::Base'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
15405
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
1
|
|
|
1
|
1
|
29075
|
my ($class, $filename) = @_; |
19
|
1
|
50
|
|
|
|
7
|
(defined $filename) |
20
|
|
|
|
|
|
|
|| croak "No file given as argument!"; |
21
|
1
|
50
|
|
|
|
30
|
(-e $filename) |
22
|
|
|
|
|
|
|
|| croak "The file given '$filename' could not be found"; |
23
|
1
|
50
|
|
|
|
7
|
my $json = File::Slurp::slurp($filename) or croak "Could not slurp JSON file '$filename' got no data"; |
24
|
1
|
|
|
|
|
222
|
my $d = JSON::Syck::Load($json); |
25
|
1
|
50
|
|
|
|
5
|
(ref($d) eq 'HASH') |
26
|
|
|
|
|
|
|
|| croak "Badly formatted JSON file '$filename'"; |
27
|
1
|
|
|
|
|
4
|
$class->{JSON} = $d; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get { |
31
|
2
|
|
|
2
|
1
|
956
|
my ($class, $key) = @_; |
32
|
2
|
50
|
|
|
|
8
|
return undef unless $key; |
33
|
2
|
50
|
|
|
|
7
|
return undef unless $class->{JSON}; |
34
|
2
|
|
|
|
|
9
|
$class->{JSON}->{$key}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#sub dicts { return () } |
38
|
|
|
|
|
|
|
#sub keywords { return () } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |