From 96004e50acb290548aad3e8dcf6b26e81eef75c2 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 20 Aug 2010 12:18:04 -0500 Subject: [PATCH] remove WebGUI::Utility::commify --- lib/WebGUI/Asset/Wobject/ProjectManager.pm | 5 +++-- lib/WebGUI/Asset/Wobject/StockData.pm | 3 ++- lib/WebGUI/Utility.pm | 22 +--------------------- t/Utility.t | 5 ----- 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/ProjectManager.pm b/lib/WebGUI/Asset/Wobject/ProjectManager.pm index 9851078b1..e19a8e8fe 100644 --- a/lib/WebGUI/Asset/Wobject/ProjectManager.pm +++ b/lib/WebGUI/Asset/Wobject/ProjectManager.pm @@ -17,6 +17,7 @@ use DateTime; use Tie::IxHash; use WebGUI::International; use WebGUI::Utility; +use Number::Format (); use WebGUI::HTML; use POSIX qw(ceil floor); use Moose; @@ -762,8 +763,8 @@ sub view { $hash->{'project.description.data'} = $project->{description}; $hash->{'project.startDate.data'} = $project->{startDate}?$datetime->epochToSet($project->{startDate}):$i18n->get("N_A"); $hash->{'project.endDate.data'} = $project->{endDate}?$datetime->epochToSet($project->{endDate}):$i18n->get("N_A"); - $hash->{'project.cost.data.int'} = WebGUI::Utility::commify(int($project->{targetBudget})); - $hash->{'project.cost.data.float'} = WebGUI::Utility::commify($project->{targetBudget}); + $hash->{'project.cost.data.int'} = Number::Format::format_number($project->{targetBudget}, 0); + $hash->{'project.cost.data.float'} = Number::Format::format_number($project->{targetBudget}); $hash->{'project.complete.data.int'} = int($project->{percentComplete}); $hash->{'project.complete.data.int'} = 100 if($hash->{'project.complete.data.int'} > 100); $hash->{'project.complete.data.float'} = sprintf("%2.2f",$project->{percentComplete}); diff --git a/lib/WebGUI/Asset/Wobject/StockData.pm b/lib/WebGUI/Asset/Wobject/StockData.pm index f71b53a2d..cbca5a378 100644 --- a/lib/WebGUI/Asset/Wobject/StockData.pm +++ b/lib/WebGUI/Asset/Wobject/StockData.pm @@ -16,6 +16,7 @@ use WebGUI::Utility; use WebGUI::Asset::Wobject; use Finance::Quote; use Tie::IxHash; +use Number::Format (); use Moose; use WebGUI::Definition::Asset; @@ -110,7 +111,7 @@ sub _appendStockVars { $hash->{'stocks.volume.millions'} = _na(WebGUI::Utility::round(($hash->{'stocks.volume'}/1000000),2)); $hash->{'stocks.avg_vol'} = _na($data->{$symbol,"avg_vol"}); $hash->{'stocks.bid'} = _na($data->{$symbol,"bid"}); - $hash->{'stocks.ask'} = _na(WebGUI::Utility::commify($data->{$symbol,"ask"})); + $hash->{'stocks.ask'} = _na(Number:Format::format_number($data->{$symbol,"ask"})); $hash->{'stocks.close'} = _na($data->{$symbol,"close"}); $hash->{'stocks.open'} = _na($data->{$symbol,"open"}); $hash->{'stocks.day_range'} = _na($data->{$symbol,"day_range"}); diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 76ebf9004..20461874e 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -22,7 +22,7 @@ use Tie::IxHash; use Net::CIDR::Lite; our @ISA = qw(Exporter); -our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray &isInSubnet +our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &randomizeArray &isInSubnet &sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round &scalarEquals ); @@ -38,7 +38,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme =head1 SYNOPSIS use WebGUI::Utility; - $string = commify($integer); $boolean = isBetween($value, $first, $second); $boolean = isIn($value, @array); $boolean = isInSubnet($ip, \@subnets); @@ -59,25 +58,6 @@ These subroutines are available from this package: =cut -#------------------------------------------------------------------- - -=head2 commify ( integer ) - -Returns a number with commas applied at each third character. - -=head3 integer - -Any old number will do. - -=cut - -sub commify { - my $text = reverse $_[0]; - $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; - return scalar reverse $text; -} - - #------------------------------------------------------------------- =head2 emailRegex ( ) diff --git a/t/Utility.t b/t/Utility.t index 07de9fea2..3c5892c39 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -22,11 +22,6 @@ use Test::Deep; my $session = WebGUI::Test->session; -# commify -is(WebGUI::Utility::commify(10), "10", 'commify() - no comma needed'); -is(WebGUI::Utility::commify(1000), "1,000", 'commify() - single comma'); -is(WebGUI::Utility::commify(10000000), "10,000,000", 'commify() - multiple commas'); - # isBetween ok(WebGUI::Utility::isBetween(0,-1,1), 'isBetween() - negative and positive range'); ok(WebGUI::Utility::isBetween(0,1,-1), 'isBetween() - negative and positive range, reversed');