File Coverage

blib/lib/WebService/Nextbus/Agency/SFMUNI.pm
Criterion Covered Total %
statement 28 59 47.4
branch 0 24 0.0
condition 1 3 33.3
subroutine 7 8 87.5
pod 0 2 0.0
total 36 96 37.5


line stmt bran cond sub pod time code
1             package WebService::Nextbus::Agency::SFMUNI;
2 1     1   3897 use 5.006;
  1         4  
  1         45  
3 1     1   6 use strict;
  1         2  
  1         37  
4 1     1   6 use warnings;
  1         2  
  1         32  
5 1     1   5 use integer;
  1         2  
  1         6  
6 1     1   3194 use Storable;
  1         8185  
  1         139  
7 1     1   17 use base qw(WebService::Nextbus::Agency);
  1         3  
  1         1698  
8              
9             our $VERSION = '0.12';
10              
11             sub new {
12 1     1 0 986 my $proto = shift;
13 1   33     6 my $class = ref($proto) || $proto;
14              
15 1         9 my $self = $class->SUPER::new;
16 1         7 $self->nameCode('sf-muni');
17 1         7 $self->routeRegExp('([fjklmns]|22)');
18 1         6 $self->dirRegExp('(fishwarf|castro|downtown|balboa|zoo|caltrain|judah|castro|marina|3rdstreet|[34bcdfijmnsz])');
19              
20             # This hack is the only way I could figure to find the serialized data
21 1         2 my $fileDir = $INC{'WebService/Nextbus/Agency/SFMUNI.pm'};
22 1         7 $fileDir =~ s/SFMUNI.pm$//;
23 1         8 $self->routes(retrieve($fileDir . 'SFMUNI.store'));
24              
25 1         8 bless ($self, $class);
26             }
27              
28             # A little hacking by an SF native for convenience
29             sub parseDir {
30 0     0 0   my $self = shift;
31 0           my ($str) = @_;
32 0           my $dirRegExp = $self->dirRegExp();
33              
34 0           my ($dir) = ($str =~ /$dirRegExp/i);
35 0           $str =~ s/$dir\s*//;
36 0           $dir = lc($dir);
37              
38             # Various translations for limited backward compatibility
39 0 0         if ($dir eq 'i') { $dir = 'downtown' }
  0            
40 0 0         if ($dir eq 'n') { $dir = 'marina' }
  0            
41 0 0         if ($dir eq 's') { $dir = 'marina' }
  0            
42              
43             # Standard translations
44 0 0         if ($dir eq '3') { $dir = '3rdstreet' }
  0            
45 0 0         if ($dir eq '4') { $dir = 'caltrain' } # 4 for 4th and King
  0            
46 0 0         if ($dir eq 'b') { $dir = 'balboa' }
  0            
47 0 0         if ($dir eq 'c') { $dir = 'castro' }
  0            
48 0 0         if ($dir eq 'd') { $dir = 'downtown' }
  0            
49 0 0         if ($dir eq 'f') { $dir = 'fishwarf' }
  0            
50 0 0         if ($dir eq 'j') { $dir = 'judah' }
  0            
51 0 0         if ($dir eq 'm') { $dir = 'marina' }
  0            
52 0 0         if ($dir eq 'z') { $dir = 'zoo' }
  0            
53              
54 0           return ($dir, $str);
55             }
56              
57             1
58             __END__