Skip Menu |

This queue is for tickets about the Finance-Quote CPAN distribution.

Report information
The Basics
Id: 64519
Status: resolved
Worked: 5 min
Priority: 0/
Queue: Finance-Quote

People
Owner: eco [...] ecocode.net
Requestors: veysey [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: TSP.pm bugfix
Date: Wed, 5 Jan 2011 22:43:48 -0500
To: bug-Finance-Quote [...] rt.cpan.org
From: John Veysey <veysey [...] gmail.com>
Hi - Line 54 ["**TSPL2010FUND => "L 2010",] needs to be eliminated, since that fund has been retired by the TSP. When this is done (and the website is updated, as per bug 63834), the module works as expected. Cheers and thanks. John
Yep. I get some joy from the attached. The table extract check is to try to give a better message when it goes wrong again in 2020 (it took me quite a while to realize what part of some quotes was going wrong).
Subject: 0001-TSP-remove-L2010-which-has-gone-and-broke-the-table-.patch
From 0631b9a72a6593144e365caefd1ac975732c4083 Mon Sep 17 00:00:00 2001 From: Kevin Ryde <user42@zip.com.au> Date: Wed, 26 Jan 2011 09:32:02 +1100 Subject: [PATCH] TSP remove L2010 which has gone and broke the table parse. die() if no table, as better error report. --- lib/Finance/Quote/TSP.pm | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Finance/Quote/TSP.pm b/lib/Finance/Quote/TSP.pm index e5cd1ed..7c574d1 100644 --- a/lib/Finance/Quote/TSP.pm +++ b/lib/Finance/Quote/TSP.pm @@ -46,11 +46,13 @@ $VERSION = '1.17'; $TSP_URL = 'https://www.tsp.gov/investmentfunds/shareprice/sharePriceHistory.shtml'; $TSP_MAIN_URL=("http://www.tsp.gov"); +# ENHANCE-ME: The decade target funds like 2020 appear and disappear. +# Better not to hard code them. +# %TSP_FUND_COLUMNS = ( TSPL2040FUND => "L 2040", TSPL2030FUND => "L 2030", TSPL2020FUND => "L 2020", - TSPL2010FUND => "L 2010", TSPLINCOMEFUND => "L INCOME", TSPGFUND => "G FUND", TSPFFUND => "F FUND", @@ -62,7 +64,6 @@ $TSP_MAIN_URL=("http://www.tsp.gov"); TSPL2040 => 'Lifecycle 2040 Fund', TSPL2030 => 'Lifecycle 2030 Fund', TSPL2020 => 'Lifecycle 2020 Fund', - TSPL2010 => 'Lifecycle 2010 Fund', TSPLINCOME => 'Lifecycle Income Fund', TSPGFUND => 'Government Securities Investment Fund', TSPFFUND => 'Fixed Income Index Investment Fund', @@ -90,7 +91,7 @@ sub tsp { # Local Variables my(%info, %fundrows); - my($ua, $reply, $row, $te); + my($ua, $reply, $row, $te, $ts); $ua = $quoter->user_agent; $reply = $ua->request(GET $TSP_URL); @@ -102,7 +103,9 @@ sub tsp { # First row is newest data, older data follows, maybe there # should be some way to get it? - $row = ($te->rows())[0]; + $ts = $te->first_table_found + || die 'TSP data table not recognised'; + $row = $ts->row(0); # Make a hash that maps the order the columns are in for(my $i=1; my $key = each %TSP_FUND_COLUMNS ; $i++) { -- 1.7.2.3
Patch applied -- Erik