From 3072c507749308df253f18f696f6a89f85a05938 Mon Sep 17 00:00:00 2001 From: Jag Talon Date: Wed, 20 Mar 2013 19:42:03 -0400 Subject: [PATCH] Removed AreaCode in favor of the Wikipedia version. --- lib/DDG/Goodie/AreaCode.pm | 93 -------------------------------------- t/AreaCode.t | 26 ----------- 2 files changed, 119 deletions(-) delete mode 100644 lib/DDG/Goodie/AreaCode.pm delete mode 100644 t/AreaCode.t diff --git a/lib/DDG/Goodie/AreaCode.pm b/lib/DDG/Goodie/AreaCode.pm deleted file mode 100644 index 8c12e9f2b..000000000 --- a/lib/DDG/Goodie/AreaCode.pm +++ /dev/null @@ -1,93 +0,0 @@ -package DDG::Goodie::AreaCode; - -use DDG::Goodie; - -zci is_cached => 1; -zci answer_type => "areacode"; - -# Regexp for AreaCode. -my $area_code_qr = qr/areacode/io; - -primary_example_queries 'area codes 209'; -description 'Find the telephone area code'; -name 'Area Code'; -code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/AreaCode.pm'; -category 'geography'; -topics 'everyday', 'geography'; -attribution web => [ 'https://www.duckduckgo.com', 'DuckDuckGo' ], - github => [ 'https://github.com/duckduckgo', 'duckduckgo'], - twitter => ['http://twitter.com/duckduckgo', 'duckduckgo']; - -triggers query_nowhitespace => qr/$area_code_qr.*(?slurp; - -foreach my $state (@states) { - chomp($state); - my @split_state = split(/=>/, $state); - $state_names{$split_state[0]} = $split_state[1]; -} - -my %area_code_check = (); -my @areas = share('area_codes.txt')->slurp; - -foreach my $area (@areas) { - chomp($area); - my @split_area = split(/=>/, $area); - $area_code_check{$split_area[0]} = $split_area[1]; -} - -handle query_nowhitespace => sub { - sub area_code_location { - my ($str, $state_names_ref) = @_; - - my ($sub_country, $country) = $str =~ /(.*), (.*)/; - grep( $_ =~ s/\"//g, ( $sub_country, $country ) ); - - if ($country eq 'US' && length($sub_country) == 2) { - $str = $$state_names_ref{uc $sub_country}; - } - elsif ($country eq 'CANADA') { - $str = "$sub_country, Canada"; - } - else { - $str = $sub_country; - } - - return $str; - } - - my $area_code = $1 || $2; - my $is_area_code = 0; - my $area_code_location = ''; - if(exists $area_code_check{$area_code}) { - $area_code_location = $area_code_check{$area_code}; - } - if ($area_code_location) { - my ($sub_country, $country) = $area_code_location =~ /(.*), (.*)/; - grep($_ =~ s/\"//g, ($sub_country, $country)); - - # Make string for display. - $area_code_location = &area_code_location($area_code_location, \%state_names); - - my $map = ''; - if ($country eq 'US' && length($sub_country) == 2 ) { - $sub_country = lc $sub_country; - $map = qq() . 'Map' . ''; - } - elsif ($country eq 'CANADA' ) { - $map = qq() . 'Map' . ''; - } - else { - my $sub_country_escape = encode_for_link($sub_country); - $map = qq() . 'Map' . ''; - } - - return "$area_code is an area code in $area_code_location", heading => "Area Codes ($area_code_location)", html => "$area_code is an area code in $area_code_location" . " - " . $map; - } - - return; -}; - -1; diff --git a/t/AreaCode.t b/t/AreaCode.t deleted file mode 100644 index 4385d2695..000000000 --- a/t/AreaCode.t +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; -use Test::More; -use DDG::Test::Goodie; - -zci answer_type => 'areacode'; -zci is_cached => 1; - -ddg_goodie_test( - [qw( DDG::Goodie::AreaCode )], - 'area code 602' => test_zci( - "602 is an area code in Arizona", - heading => 'Area Codes (Arizona)', - html => qq(602 is an area code in Arizona - Map) - ), - 'areacode 501' => test_zci( - "501 is an area code in Arkansas", - heading => 'Area Codes (Arkansas)', - html => qq(501 is an area code in Arkansas - Map) - ), -); - -done_testing; -