Skip to content

fix for the special case of ooshima-cho, saikai-shi, nagasaki-pref. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Parse/JapanesePostalCode/Row.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ sub fix_town {
if ($columns->{city} eq $name || $columns->{city} =~ /郡\Q$name\E$/) {
$columns->{town_kana} = undef;
$columns->{town} = undef;
} else {
$columns->{town_kana} =~ /^(.+)ノツギニバンチガクルバアイ/;
$columns->{town_kana} = $1;
$columns->{town} = $name;
}
} elsif ($columns->{town} =~ s/(その他)$//) {
$columns->{town_kana} =~ s/\(ソノタ\)$//;
Expand Down
14 changes: 13 additions & 1 deletion t/111_notuginibanchigakurubaai.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use t::Util;

my $parser = make_parser
q{21207,"50137","5013701","ギフケン","ミノシ","ミノシノツギニバンチガクルバアイ","岐阜県","美濃市","美濃市の次に番地がくる場合",0,0,0,0,0,0},
q{20448,"39972","3997201","ナガノケン","ヒガシチクマグンイクサカムラ","イクサカムラノツギニバンチガクルバアイ","長野県","東筑摩郡生坂村","生坂村の次に番地がくる場合",0,0,0,0,0,0};
q{20448,"39972","3997201","ナガノケン","ヒガシチクマグンイクサカムラ","イクサカムラノツギニバンチガクルバアイ","長野県","東筑摩郡生坂村","生坂村の次に番地がくる場合",0,0,0,0,0,0},
q{42212,"85724","8572427","ナガサキケン","サイカイシ","オオシマチョウノツギニバンチガクルバアイ","長崎県","西海市","大島町の次に番地がくる場合",0,0,0,0,0,0};

do {
my $row = $parser->fetch_obj;
Expand All @@ -30,4 +31,15 @@ do {
is($row->town, undef);
};

do {
my $row = $parser->fetch_obj;
is($row->zip, '8572427');
is($row->pref_kana, 'ナガサキケン');
is($row->region_kana, 'サイカイシ');
is($row->town_kana, 'オオシマチョウ');
is($row->pref, '長崎県');
is($row->region, '西海市');
is($row->town, '大島町');
};

done_testing;