From 26b152d86b556a5ca47d00dcc7841e3612f9065b Mon Sep 17 00:00:00 2001 From: Tom Bebbington Date: Wed, 26 Mar 2014 22:07:24 +0000 Subject: [PATCH] Royal Mail IA: Format code --- lib/DDG/Goodie/RoyalMail.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/DDG/Goodie/RoyalMail.pm b/lib/DDG/Goodie/RoyalMail.pm index ac40ba676..50a81ec8c 100644 --- a/lib/DDG/Goodie/RoyalMail.pm +++ b/lib/DDG/Goodie/RoyalMail.pm @@ -2,25 +2,29 @@ package DDG::Goodie::RoyalMail; use DDG::Goodie; -zci is_cached => 1; +zci is_cached => 1; zci answer_type => "royal_mail"; primary_example_queries 'royal mail RU401513974GB'; description 'Track a Royal Mail / Parcelforce parcel'; icon_url "/i/www.royalmail.com.ico"; name 'Royal Mail'; -code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/RoyalMail.pm'; +code_url + 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/RoyalMail.pm'; category 'ids'; topics 'special_interest'; -attribution github => [ 'https://github.com/TopHattedCoder', 'Tom Bebbington'], - twitter => ['http://twitter.com/TopHattedCoder', '@Tom Bebbington']; +attribution + github => [ 'https://github.com/TopHattedCoder', 'Tom Bebbington' ], + twitter => [ 'http://twitter.com/TopHattedCoder', '@Tom Bebbington' ]; # Regex for royal mail. my $rm_qr = qr/royalmail|parcelforce/io; my $tracking_qr = qr/package|parcel|track(?:ing|)|num(?:ber|)|\#/i; + # note: parcelforce format listed at http://www.parcelforce.com/help-information/frequently-asked-questions/track-parcel#2 -my $parcel = qr/[A-Z]{2}[0-9]{7}|[A-Z]{4}[0-9]{10}|[A-Z]{2}[0-9]{9}GB|[0-9]{12}|[A-Z]{2}[0-9]{9}[A-Z]{2}/i; +my $parcel + = qr/[A-Z]{2}[0-9]{7}|[A-Z]{4}[0-9]{10}|[A-Z]{2}[0-9]{9}GB|[0-9]{12}|[A-Z]{2}[0-9]{9}[A-Z]{2}/i; triggers query_nowhitespace_nodash => qr/ ^$rm_qr.*?(?$parcel)$| ^(?$parcel).*?$rm_qr$| @@ -29,7 +33,10 @@ triggers query_nowhitespace_nodash => qr/ handle query_nowhitespace_nodash => sub { my $parcel_number = $+{parcel_number}; - return $parcel_number, heading => 'Royal Mail / Parcelforce Tracking', html => qq(Track this parcel at Royal Mail or Parcelforce.); + return $parcel_number, + heading => 'Royal Mail / Parcelforce Tracking', + html => + qq(Track this parcel at Royal Mail or Parcelforce.); }; 1;