File Coverage

blib/lib/Lingua/ZH/CEDICT/Storable.pm
Criterion Covered Total %
statement 23 28 82.1
branch 1 2 50.0
condition n/a
subroutine 6 7 85.7
pod 2 3 66.6
total 32 40 80.0


line stmt bran cond sub pod time code
1             package Lingua::ZH::CEDICT::Storable;
2              
3             # Copyright (c) 2002-2005 Christian Renz
4             # This module is free software; you can redistribute it and/or modify
5             # it under the same terms as Perl itself.
6              
7 4     4   28 use strict;
  4         9  
  4         185  
8 4     4   26 use warnings;
  4         8  
  4         162  
9 4     4   24 use vars qw($VERSION @ISA);
  4         7  
  4         289  
10 4     4   3548 use Storable;
  4         13215  
  4         1456  
11              
12             $VERSION = '0.03';
13             @ISA = qw(Lingua::ZH::CEDICT);
14              
15             sub new {
16 4     4 1 10 my $class = shift;
17 4         11 my $self = +{@_};
18              
19 4 50       21 unless ($self->{filename}) {
20 4         8 $self->{filename} = __FILE__;
21 4         38 $self->{filename} =~ s/Storable\.pm/CEDICT.store/;
22             }
23 4         32 bless $self, $class;
24             }
25              
26             sub init {
27 2     2 0 21 my $self = shift;
28              
29 2         16 my $data = retrieve($self->{filename});
30              
31 2         164486 foreach (qw(version entry keysZh keysPinyin keysEn)) {
32 10         49 $self->{$_} = $data->{$_};
33             }
34 2         13 return 1;
35             }
36              
37             sub importData {
38 0     0 1   my ($self, $dict) = @_;
39              
40 0           my $data = $dict->exportData();
41              
42 0           foreach (qw(version entry keysZh keysPinyin keysEn)) {
43 0           $self->{$_} = $data->{$_};
44             }
45              
46 0           store($data, $self->{filename});
47             }
48              
49             1;
50             __END__