DE/URA.pm

filter: Statementstmt 81.0% 167 / 206 Branchbran 62.9% 34 / 54 Conditioncond 60.6% 37 / 61 MC/DCmcdc 35.1% 13 / 37 Subroutinesub 80.7% 21 / 26 Podpod 77.7% 7 / 9 totaltotal 70.9% 279 / 393 CC 53 SCAR 32.2
CC
53
Cov
74%
new
40.5
results
39.3
parse_raw_data
7.1
CRAP 25.0
↑ Summary DE/URA/Result.pm »
1 package Travel::Status::DE::URA;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶no if $] >= 5.018, warnings => 'experimental::smartmatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 our $VERSION = '2.01';
11  
12 # create CONSTANTS for different Return Types
13 5 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 TYPE_STOP => 0,
15 TYPE_PREDICTION => 1,
16 TYPE_MESSAGE => 2,
17 TYPE_BASE => 3,
18 TYPE_URA => 4,
19 5 };
20  
21 5 ▶use Carp qw(confess cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use Encode qw(encode decode);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶use List::MoreUtils qw(firstval none uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 5 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 5 ▶use Text::CSV;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use Travel::Status::DE::URA::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use Travel::Status::DE::URA::Stop;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 13 ▶sub new {
Subroutine new: called CC=18 SCAR=37.0
Pod documented
31 13 my ( $class, %opt ) = @_;
32  
33 13 ▶ my %lwp_options = %{ $opt{lwp_options} // { timeout => 10 } };
Condition50%1/2
$opt{"lwp_options"} // {"timeout", 10}
l!l
013
MC/DC0%0/1
$opt{"lwp_options"} // {"timeout", 10}
$opt{"lwp_options"}
Truth table50%1/2
A
A= $opt{"lwp_options"}
Aresult
11
00
34  
35 13 my $ua = LWP::UserAgent->new(%lwp_options);
36 13 my $response;
37  
38 13 ▶ if ( not( $opt{ura_base} and $opt{ura_version} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt{"ura_base"} and $opt{"ura_version"}) 3 10 13
Condition100%3/3
$opt{"ura_base"} and $opt{"ura_version"}
!ll&&!rl&&r
2110
MC/DC100%2/2
$opt{"ura_base"} and $opt{"ura_version"}
$opt{"ura_base"} $opt{"ura_version"}
Truth table100%3/3
A and B
A= $opt{"ura_base"}B= $opt{"ura_version"}
ABresult
0X0
100
111
39 3 confess('ura_base and ura_version are mandatory');
40 }
41  
42 my $self = {
43 datetime => $opt{datetime}
44 // DateTime->now( time_zone => 'Europe/Berlin' ),
45 developer_mode => $opt{developer_mode},
46 ura_base => $opt{ura_base},
47 ura_version => $opt{ura_version},
48 full_routes => $opt{calculate_routes} // 0,
49 hide_past => $opt{hide_past} // 1,
50 stop => $opt{stop},
51 via => $opt{via},
52 via_id => $opt{via_id},
53 stop_id => $opt{stop_id},
54 line_id => $opt{line_id},
55 circle => $opt{circle},
56 10 ▶ post => {
Condition85%6/7
$opt{"datetime"} // "DateTime"->now("time_zone", "Europe/Berlin")
l!l&&r!l&&!r
640
$opt{"calculate_routes"} // 0
l!l
19
$opt{"hide_past"} // 1
l!l
91
MC/DC0%0/2
$opt{"datetime"} // "DateTime"->now("time_zone", "Europe/Berlin")
$opt{"datetime"} "DateTime"->now("time_zone", "Europe/Berlin")
MC/DC100%1/1
$opt{"calculate_routes"} // 0
$opt{"calculate_routes"}
MC/DC100%1/1
$opt{"hide_past"} // 1
$opt{"hide_past"}
Truth table66%2/3
A // B
A= $opt{"datetime"}B= "DateTime"->now("time_zone", "Europe/Berlin")
ABresult
1X1
011
000
Truth table100%2/2
A
A= $opt{"calculate_routes"}
Aresult
11
00
Truth table100%2/2
A
A= $opt{"hide_past"}
Aresult
11
00
57 StopAlso => 'False',
58  
59 # for easier debugging ordered in the returned order
60 ReturnList => 'stoppointname,stopid,stoppointindicator,'
61 . 'latitude,longitude,lineid,linename,'
62 . 'directionid,destinationtext,vehicleid,tripid,estimatedtime'
63 },
64 };
65  
66 10 ▶ if ( $opt{with_messages} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"with_messages"}) 0 10 10
67 0 $self->{post}{ReturnList} .= ',messagetext,messagetype';
68 }
69 10 ▶ if ( $opt{with_stops} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"with_stops"}) 0 10 10
70 0 $self->{post}{StopAlso} = 'True';
71 }
72  
73 $self->{ura_instant_url}
74 10 = $self->{ura_base} . '/instant_V' . $self->{ura_version};
75  
76 10 bless( $self, $class );
77  
78 10 $ua->env_proxy;
79  
80 10 ▶ if ( substr( $self->{ura_instant_url}, 0, 5 ) ne 'file:' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($self->{'ura_instant_url'}, 0, 5) ne 'file:') { } 0 10 10
81  
82 # filter by stop_id only if full_routes is not set
83 0 ▶ if ( not $self->{full_routes} and $self->{stop_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"full_routes"} and $self->{"stop_id"}) 0 0 0
Condition0%0/3
not $self->{"full_routes"} and $self->{"stop_id"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"full_routes"} and $self->{"stop_id"}
not $self->{"full_routes"} $self->{"stop_id"}
Truth table0%0/3
not(A) and B
A= not $self->{"full_routes"}B= $self->{"stop_id"}
ABresult
0X0
100
111
84 0 $self->{post}{StopID} = $self->{stop_id};
85  
86 # filter for via as well to make via work
87 0 ▶ if ( defined $self->{via_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"via_id"}) 0 0 0
88 0 $self->{post}{StopID} .= q{,} . $self->{via_id};
89 }
90 }
91  
92 # filter by line
93 0 ▶ if ( $self->{line_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"line_id"}) 0 0 0
94 0 $self->{post}{LineID} = $self->{line_id};
95 }
96  
97 # filter for Stops in circle (lon,lat,dist)
98 0 ▶ if ( $self->{circle} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"circle"}) 0 0 0
99 0 $self->{post}{Circle} = $self->{circle};
100 }
101  
102 0 $response = $ua->post( $self->{ura_instant_url}, $self->{post} );
103 }
104 else {
105 10 $response = $ua->get( $self->{ura_instant_url} );
106 }
107  
108 10 ▶ if ( $response->is_error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_error) 1 9 10
109 1 $self->{errstr} = $response->status_line;
110 1 return $self;
111 }
112  
113 9 my $raw_str = $response->decoded_content;
114  
115 9 ▶ if ( $self->{developer_mode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"developer_mode"}) 0 9 9
116 0 say decode( 'UTF-8', $raw_str );
117 }
118  
119 # Fix encoding in case we're running through test files
120 9 ▶ if ( substr( $self->{ura_instant_url}, 0, 5 ) eq 'file:' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($self->{"ura_instant_url"}, 0, 5) eq "file:") 9 0 9
121 9 $raw_str = encode( 'UTF-8', $raw_str );
122 }
123 9 $self->parse_raw_data($raw_str);
124  
125 9 return $self;
126 }
127  
128 9 ▶sub parse_raw_data {
Subroutine parse_raw_data: called CC=7 SCAR=19.6
Pod undocumented
129 9 my ( $self, $raw_str ) = @_;
130 9 my $csv = Text::CSV->new( { binary => 1 } );
131  
132 9 for my $dep ( split( /\r\n/, $raw_str ) ) {
133 155673 $dep =~ s{^\[}{};
134 155673 $dep =~ s{\]$}{};
135  
136 155673 $csv->parse($dep);
137 155673 my @fields = $csv->fields;
138  
139 # encode all fields
140 155673 for my $i ( 1, 11 ) {
141 311346 $fields[$i] = encode( 'UTF-8', $fields[$i] );
142 }
143  
144 155673 push( @{ $self->{raw_list} }, \@fields );
145  
146 155673 my $type = $fields[0];
147  
148 155673 ▶ if ( $type == TYPE_STOP ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type == 0) { } 9891 145782 155673
elsif ($type == 2) { } 0 145782 145782
elsif ($type == 1) { } 145773 9 145782
149 9891 my $stop_name = $fields[1];
150 9891 my $stop_id = $fields[2];
151 9891 my $longitude = $fields[3];
152 9891 my $latitude = $fields[4];
153  
154 # create Stop Dict
155 9891 ▶ if ( not exists $self->{stops}{$stop_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"stops"}{$stop_id}) 9891 0 9891
156 9891 $self->{stops}{$stop_id} = Travel::Status::DE::URA::Stop->new(
157 name => decode( 'UTF-8', $stop_name ),
158 id => $stop_id,
159 longitude => $longitude,
160 latitude => $latitude,
161 );
162 }
163 }
164 elsif ( $type == TYPE_MESSAGE ) {
165 push(
166 0 @{ $self->{messages} },
167 {
168 stop_name => $fields[1],
169 stop_id => $fields[2],
170  
171 # 0 = long text. 2 = short text for station displays?
172 type => $fields[6],
173 text => $fields[7],
174 }
175 );
176 }
177 elsif ( $type == TYPE_PREDICTION ) {
178 145773 push( @{ $self->{stop_names} }, $fields[1] );
179 }
180 }
181  
182 9 @{ $self->{stop_names} } = uniq @{ $self->{stop_names} };
183  
184 9 return $self;
185 }
186  
187 3 ▶sub get_stop_by_name {
Subroutine get_stop_by_name: called CC=2 SCAR=6.9
Pod documented
188 3 my ( $self, $name ) = @_;
189  
190 3 my $nname = lc($name);
191 3 ▶ my $actual_match = firstval { $nname eq lc($_) } @{ $self->{stop_names} };
Subroutine __ANON__: called CC=1 SCAR=0.0
192  
193 3 ▶ if ($actual_match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actual_match) 2 1 3
194 2 return $actual_match;
195 }
196  
197 1 return ( grep { $_ =~ m{$name}i } @{ $self->{stop_names} } );
198 }
199  
200 0 ▶sub get_stops {
Subroutine get_stops: not called CC=1 SCAR=6.9
Pod documented
201 0 my ($self) = @_;
202  
203 0 return $self->{stops};
204 }
205  
206 2 ▶sub errstr {
Subroutine errstr: called CC=1 SCAR=0.0
Pod documented
207 2 my ($self) = @_;
208  
209 2 return $self->{errstr};
210 }
211  
212 0 ▶sub messages_by_stop_id {
Subroutine messages_by_stop_id: not called CC=1 SCAR=6.9
Pod documented
213 0 my ( $self, $stop_id ) = @_;
214  
215 0 my @messages = grep { $_->{stop_id} == $stop_id } @{ $self->{messages} };
216 0 @messages = map { $_->{text} } @messages;
217  
218 0 return @messages;
219 }
220  
221 0 ▶sub messages_by_stop_name {
Subroutine messages_by_stop_name: not called CC=1 SCAR=6.9
Pod documented
222 0 my ( $self, $stop_name ) = @_;
223  
224 my @messages
225 0 = grep { $_->{stop_name} eq $stop_name } @{ $self->{messages} };
226 0 @messages = map { $_->{text} } @messages;
227  
228 0 return @messages;
229 }
230  
231 12 ▶sub results {
Subroutine results: called CC=29 SCAR=36.7
Pod documented
232 12 my ( $self, %opt ) = @_;
233 12 my @results;
234  
235 12 ▶ my $full_routes = $opt{calculate_routes} // $self->{full_routes} // 0;
Condition60%3/5
($opt{"calculate_routes"} // $self->{"full_routes"}) // 0
l!l
120
$opt{"calculate_routes"} // $self->{"full_routes"}
l!l&&r!l&&!r
1110
MC/DC0%0/2
($opt{"calculate_routes"} // $self->{"full_routes"}) // 0
$opt{"calculate_routes"} $self->{"full_routes"}
Truth table66%2/3
A // B
A= $opt{"calculate_routes"}B= $self->{"full_routes"}
ABresult
1X1
011
000
236 12 ▶ my $hide_past = $opt{hide_past} // $self->{hide_past} // 1;
Condition60%3/5
($opt{"hide_past"} // $self->{"hide_past"}) // 1
l!l
120
$opt{"hide_past"} // $self->{"hide_past"}
l!l&&r!l&&!r
1110
MC/DC0%0/2
($opt{"hide_past"} // $self->{"hide_past"}) // 1
$opt{"hide_past"} $self->{"hide_past"}
Truth table66%2/3
A // B
A= $opt{"hide_past"}B= $self->{"hide_past"}
ABresult
1X1
011
000
237 12 ▶ my $line_id = $opt{line_id} // $self->{line_id};
Condition33%1/3
$opt{"line_id"} // $self->{"line_id"}
l!l&&r!l&&!r
0012
MC/DC0%0/2
$opt{"line_id"} // $self->{"line_id"}
$opt{"line_id"} $self->{"line_id"}
Truth table33%1/3
A // B
A= $opt{"line_id"}B= $self->{"line_id"}
ABresult
1X1
011
000
238 12 ▶ my $stop = $opt{stop} // $self->{stop};
Condition100%3/3
$opt{"stop"} // $self->{"stop"}
l!l&&r!l&&!r
525
MC/DC100%2/2
$opt{"stop"} // $self->{"stop"}
$opt{"stop"} $self->{"stop"}
Truth table100%3/3
A // B
A= $opt{"stop"}B= $self->{"stop"}
ABresult
1X1
011
000
239 12 ▶ my $stop_id = $opt{stop_id} // $self->{stop_id};
Condition33%1/3
$opt{"stop_id"} // $self->{"stop_id"}
l!l&&r!l&&!r
0012
MC/DC0%0/2
$opt{"stop_id"} // $self->{"stop_id"}
$opt{"stop_id"} $self->{"stop_id"}
Truth table33%1/3
A // B
A= $opt{"stop_id"}B= $self->{"stop_id"}
ABresult
1X1
011
000
240 12 ▶ my $via = $opt{via} // $self->{via};
Condition66%2/3
$opt{"via"} // $self->{"via"}
l!l&&r!l&&!r
2010
MC/DC50%1/2
$opt{"via"} // $self->{"via"}
$opt{"via"} $self->{"via"}
Truth table66%2/3
A // B
A= $opt{"via"}B= $self->{"via"}
ABresult
1X1
011
000
241 12 ▶ my $via_id = $opt{via_id} // $self->{via_id};
Condition33%1/3
$opt{"via_id"} // $self->{"via_id"}
l!l&&r!l&&!r
0012
MC/DC0%0/2
$opt{"via_id"} // $self->{"via_id"}
$opt{"via_id"} $self->{"via_id"}
Truth table33%1/3
A // B
A= $opt{"via_id"}B= $self->{"via_id"}
ABresult
1X1
011
000
242  
243 12 my $dt_now = $self->{datetime};
244 12 my $ts_now = $dt_now->epoch;
245  
246 12 ▶ if ( $via or $via_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($via or $via_id) 2 10 12
Condition66%2/3
$via or $via_id
l!l&&r!l&&!r
2010
MC/DC50%1/2
$via or $via_id
$via $via_id
Truth table66%2/3
A or B
A= $viaB= $via_id
ABresult
1X1
011
000
247 2 $full_routes = 1;
248 }
249  
250 12 for my $dep ( @{ $self->{raw_list} } ) {
251  
252 my (
253 $type, $stopname, $stopid, $stopindicator,
254 $longitude, $latitude, $lineid, $linename,
255 $directionid, $dest, $vehicleid, $tripid,
256 $timestamp
257 190267 ) = @{$dep};
258 190267 my ( @route_pre, @route_post );
259  
260 # only work on Prediction informations
261 190267 ▶ if ( $type != TYPE_PREDICTION ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type != 1) 12100 178167 190267
262 12100 next;
263 }
264  
265 178167 ▶ if ( $line_id and not( $lineid eq $line_id ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line_id and not $lineid eq $line_id) 0 178167 178167
Condition33%1/3
$line_id and not $lineid eq $line_id
!ll&&!rl&&r
17816700
MC/DC0%0/2
$line_id and not $lineid eq $line_id
$line_id not $lineid eq $line_id
Truth table33%1/3
A and not(B)
A= $line_idB= not $lineid eq $line_id
ABresult
0X0
100
111
266 0 next;
267 }
268  
269 178167 ▶ if ( $stop and not( $stopname eq $stop ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop and not $stopname eq $stop) 111872 66295 178167
Condition100%3/3
$stop and not $stopname eq $stop
!ll&&!rl&&r
647881507111872
MC/DC100%2/2
$stop and not $stopname eq $stop
$stop not $stopname eq $stop
Truth table100%3/3
A and not(B)
A= $stopB= not $stopname eq $stop
ABresult
0X0
100
111
270 111872 next;
271 }
272  
273 66295 ▶ if ( $stop_id and not( $stopid eq $stop_id ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_id and not $stopid eq $stop_id) 0 66295 66295
Condition33%1/3
$stop_id and not $stopid eq $stop_id
!ll&&!rl&&r
6629500
MC/DC0%0/2
$stop_id and not $stopid eq $stop_id
$stop_id not $stopid eq $stop_id
Truth table33%1/3
A and not(B)
A= $stop_idB= not $stopid eq $stop_id
ABresult
0X0
100
111
274 0 next;
275 }
276  
277 66295 ▶ if ( not $timestamp ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($timestamp) 0 66295 66295
278 0 cluck("departure element without timestamp: $dep");
279 0 next;
280 }
281  
282 66295 $timestamp /= 1000;
283  
284 66295 ▶ if ( $hide_past and $ts_now > $timestamp ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hide_past and $ts_now > $timestamp) 32394 33901 66295
Condition66%2/3
$hide_past and $ts_now > $timestamp
!ll&&!rl&&r
33901032394
MC/DC50%1/2
$hide_past and $ts_now > $timestamp
$hide_past $ts_now > $timestamp
Truth table66%2/3
A and B
A= $hide_pastB= $ts_now > $timestamp
ABresult
0X0
100
111
285 32394 next;
286 }
287  
288 33901 my $dt_dep = DateTime->from_epoch(
289 epoch => $timestamp,
290 time_zone => 'Europe/Berlin'
291 );
292 33901 my $ts_dep = $dt_dep->epoch;
293  
294 33901 ▶ if ($full_routes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($full_routes) 757 33144 33901
295 my @route
296 22577 = map { [ $_->[12] / 1000, $_->[1], $_->[2], $_->[4], $_->[5] ] }
297 12261129 grep { $_->[11] == $tripid }
298 757 grep { $_->[0] == 1 } @{ $self->{raw_list} };
299  
300 757 @route_pre = grep { $_->[0] < $ts_dep } @route;
301 757 @route_post = grep { $_->[0] > $ts_dep } @route;
302  
303 757 ▶ if ( $via
Branch: 1 branch
BranchTrueFalseTotal
if ($via and &none(sub { $_->[1] eq $via; } , @route_post)) 740 17 757
Condition100%3/3
$via and &none(sub { $_->[1] eq $via; } , @route_post)
!ll&&!rl&&r
710740
MC/DC100%2/2
$via and &none(sub { $_->[1] eq $via; } , @route_post)
$via &none(sub { $_->[1] eq $via; } , @route_post)
Truth table100%3/3
A and B
A= $viaB= &none(sub { $_->[1] eq $via; } , @route_post)
ABresult
0X0
100
111
304 10790 ▶ and none { $_->[1] eq $via } @route_post )
Subroutine __ANON__: called CC=1 SCAR=0.0
305 {
306 740 next;
307 }
308  
309 17 ▶ if ( $via_id
Branch: 1 branch
BranchTrueFalseTotal
if ($via_id and &none(sub { $_->[2] eq $via_id; } , @route_post)) 0 17 17
Condition33%1/3
$via_id and &none(sub { $_->[2] eq $via_id; } , @route_post)
!ll&&!rl&&r
1700
MC/DC0%0/2
$via_id and &none(sub { $_->[2] eq $via_id; } , @route_post)
$via_id &none(sub { $_->[2] eq $via_id; } , @route_post)
Truth table33%1/3
A and B
A= $via_idB= &none(sub { $_->[2] eq $via_id; } , @route_post)
ABresult
0X0
100
111
310 0 ▶ and none { $_->[2] eq $via_id } @route_post )
Subroutine __ANON__: not called CC=1 SCAR=6.9
311 {
312 0 next;
313 }
314  
315 17 ▶ if ($hide_past) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hide_past) 0 17 17
316 0 @route_pre = grep { $_->[0] >= $ts_now } @route_pre;
317 }
318  
319 207 @route_pre = map { $_->[0] }
320 553 sort { $a->[1] <=> $b->[1] }
321 17 map { [ $_, $_->[0] ] } @route_pre;
322 497 @route_post = map { $_->[0] }
323 1960 sort { $a->[1] <=> $b->[1] }
324 17 map { [ $_, $_->[0] ] } @route_post;
325  
326 @route_pre = map {
327 17 Travel::Status::DE::URA::Stop->new(
328 datetime => DateTime->from_epoch(
329 epoch => $_->[0],
330 time_zone => 'Europe/Berlin'
331 ),
332 name => decode( 'UTF-8', $_->[1] ),
333 id => $_->[2],
334 longitude => $_->[3],
335 latitude => $_->[4],
336 )
337 } @route_pre;
338 @route_post = map {
339 17 Travel::Status::DE::URA::Stop->new(
340 datetime => DateTime->from_epoch(
341 epoch => $_->[0],
342 time_zone => 'Europe/Berlin'
343 ),
344 name => decode( 'UTF-8', $_->[1] ),
345 id => $_->[2],
346 longitude => $_->[3],
347 latitude => $_->[4],
348 )
349 } @route_post;
350 }
351  
352 push(
353 33161 @results,
354 Travel::Status::DE::URA::Result->new(
355 datetime => $dt_dep,
356 dt_now => $dt_now,
357 line => $linename,
358 line_id => $lineid,
359 destination => $dest,
360 route_pre => [@route_pre],
361 route_post => [@route_post],
362 stop => $stopname,
363 stop_id => $stopid,
364 stop_indicator => $stopindicator,
365 )
366 );
367 }
368  
369 33161 @results = map { $_->[0] }
370 397196 sort { $a->[1] <=> $b->[1] }
371 12 map { [ $_, $_->datetime->epoch ] } @results;
372  
373 12 return @results;
374 }
375  
376 # static
377 0 ▶sub get_services {
Subroutine get_services: not called CC=1 SCAR=6.9
Pod undocumented
378 return (
379 {
380 0 ura_base => 'http://ivu.aseag.de/interfaces/ura',
381 ura_version => 1,
382 name => 'Aachener Straßenbahn und Energieversorgungs AG',
383 shortname => 'ASEAG',
384 },
385 {
386 ura_base => 'http://ura.itcs.mvg-mainz.de/interfaces/ura',
387 ura_version => 1,
388 name => 'MVG Mainz',
389 shortname => 'MvgMainz',
390 },
391 {
392 ura_base => 'http://countdown.api.tfl.gov.uk/interfaces/ura',
393 ura_version => 1,
394 name => 'Transport for London',
395 shortname => 'TfL',
396 }
397 );
398 }
399  
400 5 1;
401  
402 __END__
↑ Summary DE/URA/Result.pm »