line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Gimei::Address; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
126
|
|
4
|
5
|
|
|
5
|
|
43
|
use v5.22; |
|
5
|
|
|
|
|
15
|
|
5
|
5
|
|
|
5
|
|
19
|
use Carp; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
243
|
|
6
|
5
|
|
|
5
|
|
25
|
use File::Share qw( dist_file ); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
195
|
|
7
|
5
|
|
|
5
|
|
24
|
use YAML::XS; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
210
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
|
|
41
|
use Class::Tiny qw( |
10
|
|
|
|
|
|
|
prefecture |
11
|
|
|
|
|
|
|
city |
12
|
|
|
|
|
|
|
town |
13
|
5
|
|
|
5
|
|
25
|
); |
|
5
|
|
|
|
|
13
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $addresses; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
2
|
|
66
|
2
|
0
|
78
|
my $yaml_path = shift // dist_file( 'Data-Gimei', 'addresses.yml' ); |
19
|
2
|
50
|
|
|
|
250
|
Carp::croak("failed to load address data: $yaml_path") unless -r $yaml_path; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
11
|
$addresses = YAML::XS::LoadFile($yaml_path); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILDARGS { |
25
|
6
|
|
|
6
|
0
|
1108
|
my $class = shift; |
26
|
6
|
|
|
|
|
12
|
my %args = @_; |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
66
|
|
|
17
|
$addresses //= load(); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$args{'prefecture'} = Data::Gimei::Word->new( |
31
|
6
|
|
|
|
|
11950
|
Data::Gimei::sample( $addresses->{'addresses'}->{'prefecture'} ) ); |
32
|
|
|
|
|
|
|
$args{'city'} = Data::Gimei::Word->new( |
33
|
6
|
|
|
|
|
116
|
Data::Gimei::sample( $addresses->{'addresses'}->{'city'} ) ); |
34
|
|
|
|
|
|
|
$args{'town'} = Data::Gimei::Word->new( |
35
|
6
|
|
|
|
|
109
|
Data::Gimei::sample( $addresses->{'addresses'}->{'town'} ) ); |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
103
|
return \%args; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub to_s { |
41
|
1
|
|
|
1
|
0
|
17
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
3
|
return sprintf( "%s, %s, %s", |
44
|
|
|
|
|
|
|
$self->kanji(' '), |
45
|
|
|
|
|
|
|
$self->hiragana(' '), |
46
|
|
|
|
|
|
|
$self->katakana(' ') ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub kanji { |
50
|
8
|
|
|
8
|
0
|
481
|
my ( $self, $s ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return join $s // '', |
53
|
8
|
|
100
|
|
|
157
|
map { $_->kanji } ( $self->prefecture, $self->city, $self->town ); |
|
24
|
|
|
|
|
562
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub hiragana { |
57
|
2
|
|
|
2
|
0
|
448
|
my ( $self, $s ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return join $s // '', |
60
|
2
|
|
100
|
|
|
36
|
map { $_->hiragana } ( $self->prefecture, $self->city, $self->town ); |
|
6
|
|
|
|
|
136
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub katakana { |
64
|
2
|
|
|
2
|
0
|
424
|
my ( $self, $s ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return join $s // '', |
67
|
2
|
|
100
|
|
|
37
|
map { $_->katakana } ( $self->prefecture, $self->city, $self->town ); |
|
6
|
|
|
|
|
138
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |