diff options
author | Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org> | 2012-10-10 13:11:13 +0000 |
---|---|---|
committer | Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org> | 2012-10-10 13:11:13 +0000 |
commit | d69932da7dd1d861328fbe6c492c321ab2d022ce (patch) | |
tree | cbab877e02441bfd7e3ddd2d623305014a61799e /finance/p5-Finance-Quote | |
parent | 5d152145b34ba3583db127389c4184dfb3438de9 (diff) |
Notes
Diffstat (limited to 'finance/p5-Finance-Quote')
-rw-r--r-- | finance/p5-Finance-Quote/Makefile | 9 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/distinfo | 4 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-BSERO.pm | 188 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Bourso.pm | 91 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-TSP.pm | 13 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Tiaacref.pm | 74 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/files/patch-lib-Finance-Quote.pm | 149 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/files/patch-t-bsero.t | 50 | ||||
-rw-r--r-- | finance/p5-Finance-Quote/pkg-plist | 2 |
9 files changed, 7 insertions, 573 deletions
diff --git a/finance/p5-Finance-Quote/Makefile b/finance/p5-Finance-Quote/Makefile index 2c3c6a80d036..5bdadded6eff 100644 --- a/finance/p5-Finance-Quote/Makefile +++ b/finance/p5-Finance-Quote/Makefile @@ -2,8 +2,7 @@ # $FreeBSD$ PORTNAME= Finance-Quote -PORTVERSION= 1.17 -PORTREVISION= 2 +PORTVERSION= 1.18 CATEGORIES= finance perl5 MASTER_SITES= CPAN PKGNAMEPREFIX= p5- @@ -17,11 +16,9 @@ LICENSE_COMB= dual BUILD_DEPENDS= p5-Crypt-SSLeay>=0:${PORTSDIR}/security/p5-Crypt-SSLeay \ p5-HTML-TableExtract>=0:${PORTSDIR}/www/p5-HTML-TableExtract \ p5-HTML-Tree>=0:${PORTSDIR}/www/p5-HTML-Tree \ + p5-HTTP-Message>=0:${PORTSDIR}/www/p5-HTTP-Message \ p5-libwww>=0:${PORTSDIR}/www/p5-libwww -RUN_DEPENDS= p5-Crypt-SSLeay>=0:${PORTSDIR}/security/p5-Crypt-SSLeay \ - p5-HTML-TableExtract>=0:${PORTSDIR}/www/p5-HTML-TableExtract \ - p5-HTML-Tree>=0:${PORTSDIR}/www/p5-HTML-Tree \ - p5-libwww>=0:${PORTSDIR}/www/p5-libwww +RUN_DEPENDS:= ${BUILD_DEPENDS} PERL_CONFIGURE= yes diff --git a/finance/p5-Finance-Quote/distinfo b/finance/p5-Finance-Quote/distinfo index 92b832bc8fdf..bccd6f51cd3b 100644 --- a/finance/p5-Finance-Quote/distinfo +++ b/finance/p5-Finance-Quote/distinfo @@ -1,2 +1,2 @@ -SHA256 (Finance-Quote-1.17.tar.gz) = 10c3e7d98e71997f7e32bff5898ff5153c9ebf1b46063f91c184db8e6089e170 -SIZE (Finance-Quote-1.17.tar.gz) = 130686 +SHA256 (Finance-Quote-1.18.tar.gz) = 4240faabe0646defd4ec76ca9e111977b9e8060eaec41adeb284eb422a428393 +SIZE (Finance-Quote-1.18.tar.gz) = 147575 diff --git a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-BSERO.pm b/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-BSERO.pm deleted file mode 100644 index 1d9ea83bcfa6..000000000000 --- a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-BSERO.pm +++ /dev/null @@ -1,188 +0,0 @@ -http://github.com/pfenwick/finance-quote/commit/7de984bea80e9c5e00504ededba6897183bb8c45 - ---- lib/Finance/Quote/BSERO.pm.orig 1970-01-01 08:00:00.000000000 +0800 -+++ lib/Finance/Quote/BSERO.pm 2010-02-13 18:25:22.000000000 +0800 -@@ -0,0 +1,183 @@ -+#!/usr/bin/perl -w -+# This modules is based on the Finance::Quote::ASEGR module -+# -+# The code has been modified by Andrei Cipu <strainu@strainu.ro> to be able to -+# retrieve stock information from the Bucharest Exchange in Romania. -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -+# 02111-1307, USA -+require 5.005; -+ -+use strict; -+ -+package Finance::Quote::BSERO; -+ -+use vars qw($VERSION $BSERO_URL); -+ -+use LWP::UserAgent; -+use HTTP::Request::Common; -+use HTML::TableExtract; -+ -+$VERSION='0.1'; -+ -+my $BSERO_URL = 'http://www.bvb.ro/mobile/m_SecurityDetails.aspx?'; -+ -+ -+sub methods { return ( romania => \&bsero, -+ bsero => \&bsero, -+ europe => \&bsero); } -+{ -+ my @labels = qw/name last date isodate p_change open high low close volume currency method exchange/; -+ -+ sub labels { return (romania => \@labels, -+ bsero => \@labels, -+ europe => \@labels); } -+} -+ -+sub bsero { -+ -+ my $quoter = shift; -+ my @stocks = @_; -+ my (%info,$reply,$url,$te,$ts,$row,@cells, $ce); -+ my($my_date,$my_last,$my_p_change,$my_volume,$my_high,$my_low,$my_open); -+ my $ua = $quoter->user_agent(); -+ -+ $url = $BSERO_URL; -+ -+ foreach my $stocks (@stocks) -+ { -+ $reply = $ua->request(GET $url.join('',"s=",$stocks)); -+ -+ if ($reply->is_success) -+ { -+ -+ $te = new HTML::TableExtract(); -+ -+ $te->parse($reply->content); -+ -+ unless ( $te->tables) -+ { -+ $info {$stocks,"success"} = 0; -+ $info {$stocks,"errormsg"} = "Stock name $stocks not found"; -+ next; -+ } -+ -+ $ts = $te->first_table_found(); -+ -+ foreach $row ($ts->rows) { -+ @cells = @$row; -+ -+ # The date is not a number, so we don't bother modifying it -+ if($cells[0] eq 'Data'){ -+ $my_date = $cells[1]; -+ } -+ #The rest of the data needs to be modified -+ else { -+ foreach $ce (@cells) { -+ next unless $ce; -+ $ce =~ s/\.//; #remove thouthand separator -+ $ce =~ s/,/\./g; #replace european decimal separator with american ones -+ } -+ -+ #go through each row and get the data -+ if($cells[0] eq 'Ultimul pret'){ -+ $my_last = $cells[1]; -+ } -+ if($cells[0] eq 'Var (%)'){ -+ $my_p_change = $cells[1]; -+ } -+ if($cells[0] eq 'Volum'){ -+ $my_volume = $cells[1]; -+ } -+ if($cells[0] eq 'Pret maxim'){ -+ $my_high = $cells[1]; -+ } -+ if($cells[0] eq 'Pret minim'){ -+ $my_low = $cells[1]; -+ } -+ if($cells[0] eq 'Pret deschidere'){ -+ $my_open = $cells[1]; -+ } -+ } -+ } -+ -+ $info{$stocks, "success"} =1; -+ $info{$stocks, "exchange"} ="Bucharest Stock Exchange"; -+ $info{$stocks, "method"} ="bsero"; -+ $info{$stocks, "name"} =$stocks; -+ $info{$stocks, "last"} =$my_last; -+ $info{$stocks, "close"} =$my_last; -+ $info{$stocks, "p_change"} =$my_p_change; -+ $info{$stocks, "volume"} =$my_volume; -+ $info{$stocks, "high"} =$my_high; -+ $info{$stocks, "low"} =$my_low; -+ $info{$stocks, "open"} =$my_open; -+ -+ $quoter->store_date(\%info, $stocks, {eurodate => $my_date}); -+ -+ $info{$stocks,"currency"} = "RON"; -+ -+ } else { -+ $info{$stocks, "success"}=0; -+ $info{$stocks, "errormsg"}="Error retreiving $stocks "; -+ } -+ } -+ return wantarray() ? %info : \%info; -+ return \%info; -+} -+ -+1; -+ -+=head1 NAME -+ -+Finance::Quote::BSERO Obtain quotes from Bucharest Stock Exchange. -+ -+=head1 SYNOPSIS -+ -+ use Finance::Quote; -+ -+ $q = Finance::Quote->new; -+ -+ %info = Finance::Quote->fetch("bsero","tlv"); # Only query BSERO -+ %info = Finance::Quote->fetch("romania","brd"); # Failover to other sources OK. -+ -+=head1 DESCRIPTION -+ -+This module fetches information from the "Bucharest Stock Exchange" -+(Bursa de Valori Bucuresti), http://www.bvb.ro. All stocks are available. -+ -+This module is loaded by default on a Finance::Quote object. It's -+also possible to load it explicity by placing "BSERO" in the argument -+list to Finance::Quote->new(). -+ -+This module provides both the "bsero" and "romania" fetch methods. -+Please use the "romania" fetch method if you wish to have failover -+with future sources for Romanian stocks. Using the "bsero" method will -+guarantee that your information only comes from the Bucharest Stock Exchange. -+ -+Information obtained by this module may be covered by www.bvb.go -+terms and conditions See http://www.bvb.ro/ for details. -+ -+=head1 LABELS RETURNED -+ -+The following labels may be returned by Finance::Quote::BSERO : -+name, last, date, p_change, open, high, low, close, -+volume, currency, method, exchange. -+ -+=head1 SEE ALSO -+ -+Bucharest Stock Exchange, http://www.bvb.ro -+ -+=cut diff --git a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Bourso.pm b/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Bourso.pm deleted file mode 100644 index 19b1148b2d33..000000000000 --- a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Bourso.pm +++ /dev/null @@ -1,91 +0,0 @@ -http://github.com/pfenwick/finance-quote/commit/092599c712f19e7ddeb568340d42c816c9e1ed32 - ---- lib/Finance/Quote/Bourso.pm.orig 2009-10-06 01:39:57.000000000 +0800 -+++ lib/Finance/Quote/Bourso.pm 2010-02-13 18:25:22.000000000 +0800 -@@ -121,7 +121,7 @@ - }; - - my $symbol = $symbolline[0]->as_text; -- ($symbol) = ($symbol=~m/(\w+)-/); -+ ($symbol) = ($symbol=~m/(\w+) ?-/); - $info{$stocks,"symbol"}=$symbol; - - # retrieve NAME -@@ -139,31 +139,71 @@ - # set method - $info{$stocks,"method"} = "bourso" ; - -+ #holds table data -+ my %tempinfo; -+ - # retrieve other data - my $infoclass = ($tree->look_down('class','info1'))[0]; - unless ($infoclass) { -- $info {$stocks,"success"} = 0; -- $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; -- next ; -- }; -+ my $opcvm = ($tree->look_down('id','opcvm_headerFund_0'))[0]; -+ unless ($opcvm) { -+ $info {$stocks,"success"} = 0; -+ $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; -+ next ; -+ } -+ -+ # the stock is a delayed OPCVM -+ -+ my $infoelem = ($tree->look_down('id','content-gauche'))[0]; -+ $infoelem = ($infoelem->look_down('class','TabContenu'))[0]; -+ -+ my @rows = $infoelem->look_down('_tag','tr'); -+ foreach my $i (0..$#rows) { -+ my $row = $rows[$i]; -+ unless($row->attr('class')) { -+ next; -+ } -+ -+ my @cells = $row->look_down('_tag','td'); -+ my $keytext = ($cells[0])->as_text; -+ my $valuetext = ($cells[2])->as_text; -+ -+ $tempinfo{$keytext} = $valuetext; -+ } -+ } -+ else { - - my $keys = ($infoclass->look_down('class','t01'))[0]; # this div contains all keys - my $data = ($infoclass->look_down('class','t03'))[0]; # this div contains all values - my @keys = $keys->look_down('_tag','li'); - my @values = $data->look_down('_tag','li'); - -- my %tempinfo; #holds table data -- - foreach my $i (0..$#keys) { - my $keytext = ($keys[$i])->as_text; - my $valuetext = ($values[$i])->as_text; - $tempinfo{$keytext} = $valuetext; - } - -+ } -+ - foreach my $key (keys %tempinfo) { - # print "$key -> $tempinfo{$key}\n"; - - ASSIGN: for ( $key ) { -+ # OPCVM -+ /Valeur liquidative/ && do { -+ my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\s*(\w*)/); -+ $info{$stocks,"last"} = $last; -+ $info{$stocks,"currency"} = $currency; -+ }; -+ /Date/ && do { -+ $info{$stocks,"date"} = $tempinfo{$key}; -+ $quoter->store_date(\%info, $stocks, {eurodate => $info{$stocks,"date"}}); -+ }; -+ /Variation Veille/ && do { -+ $info{$stocks,"p_change"}=$tempinfo{$key} -+ }; -+ # REGULAR STOCK - /Cours/ && do { - my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\(c\)\s*(\w*)/); - $info{$stocks,"last"} = $last; diff --git a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-TSP.pm b/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-TSP.pm deleted file mode 100644 index 7148061bbce6..000000000000 --- a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-TSP.pm +++ /dev/null @@ -1,13 +0,0 @@ -http://github.com/pfenwick/finance-quote/commit/97f8741c90af7c637c2fc990c4245c7e56eb3087 - ---- lib/Finance/Quote/TSP.pm.orig 2009-10-06 01:39:57.000000000 +0800 -+++ lib/Finance/Quote/TSP.pm 2010-11-05 19:26:46.000000000 +0800 -@@ -43,7 +43,7 @@ - - # URLs of where to obtain information - --$TSP_URL = 'http://www.tsp.gov/rates/share-prices.html'; -+$TSP_URL = 'https://www.tsp.gov/investmentfunds/shareprice/sharePriceHistory.shtml'; - $TSP_MAIN_URL=("http://www.tsp.gov"); - - %TSP_FUND_COLUMNS = ( diff --git a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Tiaacref.pm b/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Tiaacref.pm deleted file mode 100644 index 9237f8325213..000000000000 --- a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote-Tiaacref.pm +++ /dev/null @@ -1,74 +0,0 @@ -http://github.com/pfenwick/finance-quote/commit/b897e9e2a328396480a7ef21fad2c94f8357baa6 - ---- lib/Finance/Quote/Tiaacref.pm.orig 2009-10-06 01:39:57.000000000 +0800 -+++ lib/Finance/Quote/Tiaacref.pm 2010-11-05 19:34:30.000000000 +0800 -@@ -44,7 +44,8 @@ - - # URLs of where to obtain information. - # This used to be different for the CREF and TIAA annuities, but this changed. --$CREF_URL = ("https://www3.tiaa-cref.org/ddata/DownloadData?"); -+$CREF_URL = ("http://www.tiaa-cref.org/public/performance/retirement/data/results?"); -+#https://www3.tiaa-cref.org/ddata/DownloadData?"); - - sub methods { return (tiaacref=>\&tiaacref); } - -@@ -256,9 +257,21 @@ - my($ua,$urlc,$urlt); #useragent and target urls - my($cntc,$cntt); #counters for each of the two url containers - my($reply,$qdata); #the reply from TIAA-CREF's cgi and a buffer for the data -+ my $cbResult = 'cbResults='; -+ -+ my ($Fsec,$Fmin,$Fhour,$Fmday,$Fmon,$Fyear,$Fwday,$Fyday,$Fisdst) = localtime(time() - 24 * 60 * 60); -+ my ($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime(time()); -+ -+ $urlc = $CREF_URL; -+ $urlc .= "page=input"; -+ $urlc .= "&frommonth=" . ($Fmon + 1); -+ $urlc .= "&fromday=" . ($Fmday); -+ $urlc .= "&fromyear=" . ($Fyear + 1900); -+ $urlc .= "&tomonth=" . ($Tmon + 1); -+ $urlc .= "&today=" . ($Tmday); -+ $urlc .= "&toyear=" . ($Tyear + 1900); -+ $urlc .= "&sqlorder=desc&dldformat=1&submit.x=29&submit.y=7"; - --# $url = $TIAACREF_URL; -- $urlc = $CREF_URL; - $urlt = $TIAA_URL; - #Initialize counters for the two types of URL. If either counter is zero, then - # that URL will not be retrieved. This is less technically clever than testing -@@ -269,7 +282,8 @@ - if ($tiaacref_ids{$fund}) { - if ($tiaacref_locs{$fund} == 1) { - $cntc++; -- $urlc .= "f" . $cntc . "=" . $tiaacref_vals{$fund} . "&"; -+ $urlc .= "&fundid" . $tiaacref_vals{$fund} . "=" . $tiaacref_vals{$fund}; -+ $cbResult .= ($cntc > 1) ? ( "%2C" . $tiaacref_vals{$fund}) : ($tiaacref_vals{$fund}) - } else { - $urlt .= $fund . "=yes&"; - $cntt++; -@@ -280,8 +294,7 @@ - $info{$fund,"errormsg"} = "Bad symbol"; - } - } -- $urlc .= "days=1"; -- $urlc .= "&dldformat=1"; -+ $urlc .= "&$cbResult"; - $urlt .= "selected=1"; - $qdata =""; - -@@ -298,9 +311,14 @@ - $qdata .= $reply->content; - } - } -+ - if (length($qdata)) { -- foreach (split('\012',$qdata) ){ -+ foreach (split(/<br .>/,$qdata) ){ -+ next unless m/.+,.+/; -+ s/^ +//g; -+ s/ +$//g; - @line = $quoter->parse_csv($_); -+ - if (exists $check{$line[0]}) { #did we ask for this data? - $info{$line[0],"symbol"} = $line[0]; #in case the caller needs this in the hash - $info{$line[0],"exchange"} = "TIAA-CREF"; diff --git a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote.pm b/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote.pm deleted file mode 100644 index f0a61431aa1e..000000000000 --- a/finance/p5-Finance-Quote/files/patch-lib-Finance-Quote.pm +++ /dev/null @@ -1,149 +0,0 @@ ---- lib/Finance/Quote.pm.orig 2012-08-31 15:38:42.023832749 +0200 -+++ lib/Finance/Quote.pm 2012-08-31 15:42:45.299834285 +0200 -@@ -35,7 +35,6 @@ - use Carp; - use Finance::Quote::UserAgent; - use HTTP::Request::Common; --use HTML::TreeBuilder; - use Encode; - use Data::Dumper; - -@@ -43,7 +42,14 @@ - $VERSION $TIMEOUT %MODULES %METHODS $AUTOLOAD - $YAHOO_CURRENCY_URL $USE_EXPERIMENTAL_UA/; - --$YAHOO_CURRENCY_URL = "http://uk.finance.yahoo.com/q?s="; -+# Call on the Yahoo API: -+# - "f=l1" should return a single value - the "Last Trade (Price Only)" -+# - "s=" the value of s should be "<FROM><TO>=X" -+# where <FROM> and <TO> are currencies -+# Excample: http://finance.yahoo.com/d/quotes.csv?f=l1&s=AUDGBP=X -+# Documentation can be found here: -+# http://code.google.com/p/yahoo-finance-managed/wiki/csvQuotesDownload -+$YAHOO_CURRENCY_URL = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=l1&s="; - - @ISA = qw/Exporter/; - @EXPORT = (); -@@ -240,26 +246,13 @@ - - my $ua = $this->user_agent; - -- my $data = $ua->request(GET "${YAHOO_CURRENCY_URL}$from$to%3DX")->content; -- # The web page returns utf8 content which gives a warning when parsing $data -- # in HTML::Parser -- my $tb = HTML::TreeBuilder->new_from_content(decode_utf8($data)); -- -- # Find the <div> with the data -- my $div = $tb->look_down('id','yfi_quote_summary_data'); -- # Make sure there's a <div> to parse. -- return undef unless $div; -- -- # The first <b> should contain the quote -- my $rate_element=$div->look_down('_tag','b'); -- # Make sure there's a <b> to parse. -- return undef unless $rate_element; -- -- my $exchange_rate=$rate_element->as_text; -- -- $exchange_rate =~ s/,// ; # solve a bug when conversion rate -- # involves thousands. yahoo inserts -- # a comma when thousands occur -+ # The response should be a single value (the exchange rate) -+ my $data = $ua->request(GET "${YAHOO_CURRENCY_URL}${from}${to}=X")->content; -+ my $exchange_rate = $data; -+ -+ $exchange_rate =~ s/,// ; # solve a bug when conversion rate -+ # involves thousands. yahoo inserts -+ # a comma when thousands occur - - { - local $^W = 0; # Avoid undef warnings. -@@ -268,6 +261,18 @@ - # we may have extra cruft, or no amount. - return undef unless ($exchange_rate+0); - } -+ -+if ( $exchange_rate < 0.001 ) { -+ # exchange_rate is too little. we'll get more accuracy by using -+ # the inverse rate and inverse it -+ my $inverse_rate = $this->currency( $to, $from ); -+ { -+ local $^W = 0; -+ return undef unless ( $exchange_rate + 0 ); -+ } -+ $exchange_rate = int( 100000000 / $inverse_rate + .5 ) / 100000000; -+} -+ - return ($exchange_rate * $amount); - } - -@@ -770,6 +775,60 @@ - return $retTime; - } - -+ -+# If $str ends with a B like "20B" or "1.6B" then expand it as billions like -+# "20000000000" or "1600000000". -+# -+# This is done with string manipulations so floating-point rounding doesn't -+# produce spurious digits for values like "1.6" which aren't exactly -+# representable in binary. -+# -+# Is "B" for billions the only abbreviation from Yahoo? -+# Could extend and rename this if there's also millions or thousands. -+# -+# For reference, if the value was just for use within perl then simply -+# substituting to exponential "1.5e9" might work. But expanding to full -+# digits seems a better idea as the value is likely to be printed directly -+# as a string. -+sub B_to_billions { -+ -+ my ($self,$str) = @_; -+ ### B_to_billions(): $str -+ if ($str =~ s/B$//i) { -+ $str = $self->decimal_shiftup ($str, 9); -+ } -+ return $str; -+} -+ -+# $str is a number like "123" or "123.45" -+# return it with the decimal point moved $shift places to the right -+# must have $shift>=1 -+# eg. decimal_shiftup("123",3) -> "123000" -+# decimal_shiftup("123.45",1) -> "1234.5" -+# decimal_shiftup("0.25",1) -> "2.5" -+# -+sub decimal_shiftup { -+ my ($self, $str, $shift) = @_; -+ -+ # delete decimal point and set $after to count of chars after decimal. -+ # Leading "0" as in "0.25" is deleted too giving "25" so as not to end up -+ # with something that might look like leading 0 for octal. -+ my $after = ($str =~ s/(?:^0)?\.(.*)/$1/ ? length($1) : 0); -+ -+ $shift -= $after; -+ # now $str is an integer and $shift is relative to the end of $str -+ -+ if ($shift >= 0) { -+ # moving right, eg. "1234" becomes "12334000" -+ return $str . ('0' x $shift); # extra zeros appended -+ } else { -+ # negative means left, eg. "12345" becomes "12.345" -+ # no need to prepend zeros since demanding initial $shift>=1 -+ substr ($str, $shift,0, '.'); # new '.' at shifted spot from end -+ return $str; -+ } -+} -+ - # Dummy destroy function to avoid AUTOLOAD catching it. - sub DESTROY { return; } - -@@ -803,7 +862,7 @@ - This module gets stock quotes from various internet sources, including - Yahoo! Finance, Fidelity Investments, and the Australian Stock Exchange. - There are two methods of using this module -- a functional interface --that is depreciated, and an object-orientated method that provides -+that is deprecated, and an object-orientated method that provides - greater flexibility and stability. - - With the exception of straight currency exchange rates, all information diff --git a/finance/p5-Finance-Quote/files/patch-t-bsero.t b/finance/p5-Finance-Quote/files/patch-t-bsero.t deleted file mode 100644 index fd3edfcf3dfc..000000000000 --- a/finance/p5-Finance-Quote/files/patch-t-bsero.t +++ /dev/null @@ -1,50 +0,0 @@ -http://github.com/pfenwick/finance-quote/commit/7de984bea80e9c5e00504ededba6897183bb8c45 - ---- t/bsero.t.orig 1970-01-01 08:00:00.000000000 +0800 -+++ t/bsero.t 2010-02-13 18:25:22.000000000 +0800 -@@ -0,0 +1,45 @@ -+#!/usr/bin/perl -w -+use strict; -+use Test; -+use Data::Dumper; -+BEGIN {plan tests => 26}; -+ -+use Finance::Quote; -+ -+# Test BSERO functions. -+ -+my $q = Finance::Quote->new(); -+my @stocks = ("TLV", "BRD", "SNP"); -+ -+my %regexps = ( -+ TLV => qr/\bTLV\b/, -+ BRD => qr/\bBRD\b/, -+ SNP => qr/\bSNP\b/, -+); -+ -+ -+my %quotes = $q->fetch("bsero", @stocks); -+ok(%quotes); -+ -+foreach my $stock (@stocks) { -+ -+ my $name = $quotes{$stock, "name"}; -+ print "#Testing $stock: $name\n"; -+ -+ my $regexp = $regexps{$stock}; -+ ok($name =~ /$regexp/i); -+ -+ ok($quotes{$stock, "exchange"} eq 'Bucharest Stock Exchange'); -+ ok($quotes{$stock, "method"} eq 'bsero'); -+ -+ ok($quotes{$stock, "last"} > 0); -+ ok($quotes{$stock, "open"} =~ /^-?\d+\.\d+$/); -+ ok($quotes{$stock, "p_change"} =~ /^-?\d+\.\d+$/); -+ ok($quotes{$stock, "success"}); -+ ok($quotes{$stock, "volume"} >= 0); -+} -+ -+ -+# Check that a bogus stock returns no-success. -+%quotes = $q->fetch("tsx", "BOGUS"); -+ok(! $quotes{"BOGUS","success"}); diff --git a/finance/p5-Finance-Quote/pkg-plist b/finance/p5-Finance-Quote/pkg-plist index 7ad99971b307..bbad419be6fb 100644 --- a/finance/p5-Finance-Quote/pkg-plist +++ b/finance/p5-Finance-Quote/pkg-plist @@ -26,6 +26,8 @@ %%SITE_PERL%%/Finance/Quote/NZX.pm %%SITE_PERL%%/Finance/Quote/Platinum.pm %%SITE_PERL%%/Finance/Quote/SEB.pm +%%SITE_PERL%%/Finance/Quote/SIXfunds.pm +%%SITE_PERL%%/Finance/Quote/SIXshares.pm %%SITE_PERL%%/Finance/Quote/StockHouseCanada.pm %%SITE_PERL%%/Finance/Quote/TSP.pm %%SITE_PERL%%/Finance/Quote/TSX.pm |