App/Chart/Gtk2/Job/Intraday.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 71 CC 3 SCAR 14.2
CC
3
Cov
0%
start
12.0
type
2.0
find
2.0
CRAP 4.1
1 # Copyright 2008, 2009, 2010, 2011, 2012 Kevin Ryde
2  
3 # This file is part of Chart.
4 #
5 # Chart is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3, or (at your option) any later version.
8 #
9 # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Chart. If not, see <http://www.gnu.org/licenses/>.
16  
17 package App::Chart::Gtk2::Job::Intraday;
18 use strict;
19 use warnings;
20 use Carp;
21 use Gtk2;
22 use Locale::TextDomain ('App-Chart');
23  
24 use App::Chart::Gtk2::Job;
25 use App::Chart::Gtk2::JobQueue;
26  
27 # uncomment this to run the ### lines
28 #use Smart::Comments;
29  
30  
31 use Glib::Object::Subclass
32 'App::Chart::Gtk2::Job',
33 properties => [ Glib::ParamSpec->string
34 ('symbol',
35 __('Symbol'),
36 'Blurb.',
37 '',
38 Glib::G_PARAM_READWRITE),
39  
40 Glib::ParamSpec->string
41 ('mode',
42 'Mode',
43 'Blurb.',
44 '',
45 Glib::G_PARAM_READWRITE),
46 ];
47  
48 sub type {
49 return __('Intraday');
50 }
51  
52 sub start {
53 my ($class, $symbol, $mode) = @_;
54 if (my $job = $class->find ($symbol, $mode)) {
55 if ($job->is_stoppable) {
56 ### still running: $job, $symbol, $mode
57 return $job;
58 }
59 }
60 return $class->SUPER::start (args => [ 'intraday', $symbol, $mode ],
61 name => __x('Intraday {symbol} {mode}',
62 symbol => $symbol,
63 mode => $mode),
64 symbol => $symbol,
65 mode => $mode,
66 status => __('Downloading ...'));
67 }
68  
69 sub find {
70 my ($class, $symbol, $mode) = @_;
71 require App::Chart::Gtk2::JobQueue;
72 my @jobs = grep { $_->{'symbol'} eq $symbol && $_->{'mode'} eq $mode }
73 App::Chart::Gtk2::JobQueue->all_jobs ($class);
74 return List::Util::first { $_->is_stoppable }
75 || $jobs[0];
76 }
77  
78 1;
79 __END__