App/Chart/Weblink/SandP.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran n/a Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 58 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
url
2.0
BEGIN
2.0
CRAP 2.0
1 # Standard and Poors web links.
2  
3 # Copyright 2007, 2008, 2009, 2010, 2016 Kevin Ryde
4  
5 # This file is part of Chart.
6 #
7 # Chart is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any later
10 # version.
11 #
12 # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 # details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Chart. If not, see <http://www.gnu.org/licenses/>.
19  
20  
21 package App::Chart::Weblink::SandP;
22 use 5.008;
23 use strict;
24 use warnings;
25 use Carp;
26 use Locale::TextDomain ('App-Chart');
27  
28 use App::Chart::Glib::Ex::MoreUtils;
29 use App::Chart;
30 use base 'App::Chart::Weblink';
31  
32 sub new {
33 my ($class, %options) = @_;
34 my $symbol_table = $options{'symbol_table'}
35 || croak 'Missing symbol_table';
36  
37 # symbols with an entry in %$symbol_table, if not otherwise given
38 $options{'pred'} ||= App::Chart::Sympred::Proc->new
39 (sub { return exists $symbol_table->{$_[0]} });
40  
41 return $class->SUPER::new
42 (%options,
43 name => __('Standard and _Poors index information'),
44 desc => __('Open web browser at the Standard and Poors web site page for this index'),
45 proc => 'subclass');
46 }
47  
48 # language choices at page
49 # http://www2.standardandpoors.com/portal/site/sp/en/au/page.siteselection/site_selection/0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0.html
50 # the ones applied here are just those which follow the basic pattern
51 #
52 sub url {
53 my ($self, $symbol) = @_;
54 my $url = $self->{'url_pattern'};
55  
56 my $lang = App::Chart::Glib::Ex::MoreUtils::lang_select (en => 'en/us',
57 es => 'es/la',
58 pt => 'pt/la');
59 $url =~ s/{lang}/$lang/;
60  
61 $symbol = $self->{'symbol_table'}->{$symbol};
62 $url =~ s/{symbol}/$symbol/;
63  
64 return $url;
65 }
66  
67 1;
68 __END__