QuoteHist/DailyFinance.pm

filter: Statementstmt 47.3% 18 / 38 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 32.8% 24 / 73 CC 7 SCAR 34.2
CC
7
Cov
33%
url_maker
56.0
__ANON__
2.0
BEGIN
1.0
CRAP 30.7
« QuoteHist/StockNod.pm ↑ Summary QuoteHist/Yahoo.pm »
1 package Finance::QuoteHist::DailyFinance;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 $VERSION = '1.00';
8  
9 1 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Finance::QuoteHist::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 @ISA = qw(Finance::QuoteHist::Generic);
13  
14 # Example URL:
15 #
16 # http://www.motleyfool.idmanagedsolutions.com/stocks/historical_quotes.idms?START_DATE=2011-06-01&END_DATE=2012-11-01&CODE_MARKET=US,@US&SYMBOL_US=IBM&BLOCKSIZE=100&OFFSET=1
17 # http://www.motleyfool.idmanagedsolutions.com/stocks/historical_quotes.idms?START_DATE=2011-06-01&END_DATE=2012-11-01&CODE_MARKET=US,@US&SYMBOL_US=IBM&BLOCKSIZE=100&OFFSET=2
18  
19 sub url_maker {
20 0 ▶ my($self, %parms) = @_;
Subroutine url_maker: not called CC=7 SCAR=40.3
Pod documented
21 0 ▶ my $target_mode = $parms{target_mode} || $self->target_mode;
Condition0%0/3
$parms{'target_mode'} || $self->target_mode
l!l&&r!l&&!r
000
MC/DC0%0/2
$parms{'target_mode'} || $self->target_mode
$parms{'target_mode'} $self->target_mode
Truth table0%0/3
A || B
A= $parms{'target_mode'}B= $self->target_mode
ABresult
1X1
011
000
22 0 ▶ my $parse_mode = $parms{parse_mode} || $self->parse_mode;
Condition0%0/3
$parms{'parse_mode'} || $self->parse_mode
l!l&&r!l&&!r
000
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'} $self->parse_mode
Truth table0%0/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
ABresult
1X1
011
000
23  
24 # *always* block uknown target mode and parse mode combinations in
25 # order for cascade to work!
26 return undef unless
27 0 ▶ ($target_mode eq 'quote') && $parse_mode eq 'html';
Branch: 1 branch
BranchTrueFalseTotal
unless $target_mode eq "quote" and $parse_mode eq "html" 0 0 0
Condition0%0/3
$target_mode eq "quote" and $parse_mode eq "html"
!ll&&!rl&&r
000
MC/DC0%0/2
$target_mode eq "quote" and $parse_mode eq "html"
$target_mode eq "quote" $parse_mode eq "html"
Truth table0%0/3
A and B
A= $target_mode eq "quote"B= $parse_mode eq "html"
ABresult
0X0
100
111
28  
29 my($ticker, $start_date, $end_date) =
30 0 @parms{qw(symbol start_date end_date)};
31 0 ▶ $start_date ||= $self->start_date;
Condition0%0/3
$start_date ||= $self->start_date
l!l&&r!l&&!r
000
MC/DC0%0/2
$start_date ||= $self->start_date
$start_date $self->start_date
Truth table0%0/3
A ||= B
A= $start_dateB= $self->start_date
ABresult
1X1
011
000
32 0 ▶ $end_date ||= $self->end_date;
Condition0%0/3
$end_date ||= $self->end_date
l!l&&r!l&&!r
000
MC/DC0%0/2
$end_date ||= $self->end_date
$end_date $self->end_date
Truth table0%0/3
A ||= B
A= $end_dateB= $self->end_date
ABresult
1X1
011
000
33  
34 0 my($sy, $sm, $sd) = $self->ymd($start_date);
35 0 my($ey, $em, $ed) = $self->ymd($end_date);
36  
37  
38 0 my $host = 'www.motleyfool.idmanagedsolutions.com';
39 0 my $path = 'stocks/historical_quotes.idms';
40  
41 0 my %query = (
42 START_DATE => "$sy-$sm-$sd",
43 END_DATE => "$ey-$em-$ed",
44 SYMBOL_US => $ticker,
45 CODE_MARKET => 'US,@US',
46 BLOCK_SIZE => 100,
47 );
48  
49 0 my $offset=0;
50  
51 sub {
52 0 ▶ $query{OFFSET} = $offset;
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 my $url = "http://$host/$path?" .
54 0 join('&', map { "$_=$query{$_}" } sort keys %query);
55 0 print STDERR "URL: $url\n" if DEBUG;
56 0 ++$offset;
57 0 return $url;
58 0 };
59 }
60  
61 1 1;
62  
63 __END__
« QuoteHist/StockNod.pm ↑ Summary QuoteHist/Yahoo.pm »