Loading bin/efa-m +39 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ use strict; use warnings; use 5.010; use utf8; no if $] >= 5.018, warnings => "experimental::smartmatch"; Loading Loading @@ -80,6 +81,31 @@ sub show_version { exit 0; } sub format_route { my (@route) = @_; my $output = q{}; for my $stop (@route) { if ( not $stop ) { say "BUG"; next; } if ( $stop->{arr_time} eq $stop->{dep_time} ) { $output .= sprintf( " %5s %40s %s\n", $stop->{dep_time}, $stop->{stop}, $stop->{platform}, ); } else { $output .= sprintf( "%5s → %5s %40s %s\n", $stop->{arr_time}, $stop->{dep_time}, $stop->{stop}, $stop->{platform}, ); } } return $output; } sub display_result { my (@lines) = @_; Loading Loading @@ -108,6 +134,10 @@ sub display_result { join( q{ }, ( map { "%-${_}s" } @line_length ) ) . "\n", @{$line}[ 0 .. 3 ] ); if ( $line->[5] and $full_routes ) { say $line->[5]; } } return; Loading Loading @@ -136,6 +166,7 @@ sub show_results { for my $d ( $status->results ) { my @output_line; my $platform = $d->platform; my $dtime = ( $relative_times ? sprintf( '%2d min', $d->countdown ) : $d->time ); Loading Loading @@ -166,8 +197,14 @@ sub show_results { $dtime .= ' (+' . $d->delay . ')'; } push( @output, [ $dtime, $platform, $d->line, $d->destination, $d->info ] ); @output_line = ( $dtime, $platform, $d->line, $d->destination, $d->info ); if ($full_routes) { $output_line[5] = format_route( $d->route_post ); } push( @output, \@output_line ); } display_result(@output); Loading lib/Travel/Status/DE/EFA.pm +46 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ sub new { if ( $opt{full_routes} ) { $self->{post}->{depType} = 'stopEvents'; $self->{post}->{includeCompleteStopSeq} = 1; $self->{want_full_routes} = 1; } bless( $self, $class ); Loading Loading @@ -292,6 +293,35 @@ sub lines { return @lines; } sub parse_route { my ( $self, @nodes ) = @_; my $xp_routepoint_date = XML::LibXML::XPathExpression->new('./itdDateTime/itdDate'); my $xp_routepoint_time = XML::LibXML::XPathExpression->new('./itdDateTime/itdTime'); my @ret; for my $e (@nodes) { my @dates = $e->findnodes($xp_routepoint_date); my @times = $e->findnodes($xp_routepoint_time); push( @ret, { arr_date => sprintf_date( $dates[0] ), arr_time => sprintf_time( $times[0] ), dep_date => sprintf_date( $dates[-1] ), dep_time => sprintf_time( $times[-1] ), stop => decode( 'UTF-8', $e->getAttribute('name') ), platform => $e->getAttribute('platformName'), } ); } return @ret; } sub results { my ($self) = @_; my @results; Loading @@ -309,6 +339,10 @@ sub results { my $xp_line = XML::LibXML::XPathExpression->new('./itdServingLine'); my $xp_info = XML::LibXML::XPathExpression->new('./itdServingLine/itdNoTrain'); my $xp_prev_route = XML::LibXML::XPathExpression->new('./itdPrevStopSeq/itdPoint'); my $xp_next_route = XML::LibXML::XPathExpression->new('./itdOnwardStopSeq/itdPoint'); if ( $self->{results} ) { return @{ $self->{results} }; Loading Loading @@ -349,6 +383,16 @@ sub results { my $platform_is_db = 0; my @prev_route; my @next_route; if ( $self->{want_full_routes} ) { @prev_route = $self->parse_route( @{ [ $e->findnodes($xp_prev_route) ] } ); @next_route = $self->parse_route( @{ [ $e->findnodes($xp_next_route) ] } ); } my @line_obj = grep { $_->{identifier} eq $e_line->getAttribute('stateless') } @{ $self->{lines} }; Loading Loading @@ -395,6 +439,8 @@ sub results { sched_date => $date, sched_time => $time, type => $type, prev_route => \@prev_route, next_route => \@next_route, ) ); } Loading lib/Travel/Status/DE/EFA/Result.pm +12 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,18 @@ sub new { return bless( $ref, $obj ); } sub route_pre { my ($self) = @_; return @{ $self->{prev_route} }; } sub route_post { my ($self) = @_; return @{ $self->{next_route} }; } sub TO_JSON { my ($self) = @_; Loading Loading
bin/efa-m +39 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ use strict; use warnings; use 5.010; use utf8; no if $] >= 5.018, warnings => "experimental::smartmatch"; Loading Loading @@ -80,6 +81,31 @@ sub show_version { exit 0; } sub format_route { my (@route) = @_; my $output = q{}; for my $stop (@route) { if ( not $stop ) { say "BUG"; next; } if ( $stop->{arr_time} eq $stop->{dep_time} ) { $output .= sprintf( " %5s %40s %s\n", $stop->{dep_time}, $stop->{stop}, $stop->{platform}, ); } else { $output .= sprintf( "%5s → %5s %40s %s\n", $stop->{arr_time}, $stop->{dep_time}, $stop->{stop}, $stop->{platform}, ); } } return $output; } sub display_result { my (@lines) = @_; Loading Loading @@ -108,6 +134,10 @@ sub display_result { join( q{ }, ( map { "%-${_}s" } @line_length ) ) . "\n", @{$line}[ 0 .. 3 ] ); if ( $line->[5] and $full_routes ) { say $line->[5]; } } return; Loading Loading @@ -136,6 +166,7 @@ sub show_results { for my $d ( $status->results ) { my @output_line; my $platform = $d->platform; my $dtime = ( $relative_times ? sprintf( '%2d min', $d->countdown ) : $d->time ); Loading Loading @@ -166,8 +197,14 @@ sub show_results { $dtime .= ' (+' . $d->delay . ')'; } push( @output, [ $dtime, $platform, $d->line, $d->destination, $d->info ] ); @output_line = ( $dtime, $platform, $d->line, $d->destination, $d->info ); if ($full_routes) { $output_line[5] = format_route( $d->route_post ); } push( @output, \@output_line ); } display_result(@output); Loading
lib/Travel/Status/DE/EFA.pm +46 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ sub new { if ( $opt{full_routes} ) { $self->{post}->{depType} = 'stopEvents'; $self->{post}->{includeCompleteStopSeq} = 1; $self->{want_full_routes} = 1; } bless( $self, $class ); Loading Loading @@ -292,6 +293,35 @@ sub lines { return @lines; } sub parse_route { my ( $self, @nodes ) = @_; my $xp_routepoint_date = XML::LibXML::XPathExpression->new('./itdDateTime/itdDate'); my $xp_routepoint_time = XML::LibXML::XPathExpression->new('./itdDateTime/itdTime'); my @ret; for my $e (@nodes) { my @dates = $e->findnodes($xp_routepoint_date); my @times = $e->findnodes($xp_routepoint_time); push( @ret, { arr_date => sprintf_date( $dates[0] ), arr_time => sprintf_time( $times[0] ), dep_date => sprintf_date( $dates[-1] ), dep_time => sprintf_time( $times[-1] ), stop => decode( 'UTF-8', $e->getAttribute('name') ), platform => $e->getAttribute('platformName'), } ); } return @ret; } sub results { my ($self) = @_; my @results; Loading @@ -309,6 +339,10 @@ sub results { my $xp_line = XML::LibXML::XPathExpression->new('./itdServingLine'); my $xp_info = XML::LibXML::XPathExpression->new('./itdServingLine/itdNoTrain'); my $xp_prev_route = XML::LibXML::XPathExpression->new('./itdPrevStopSeq/itdPoint'); my $xp_next_route = XML::LibXML::XPathExpression->new('./itdOnwardStopSeq/itdPoint'); if ( $self->{results} ) { return @{ $self->{results} }; Loading Loading @@ -349,6 +383,16 @@ sub results { my $platform_is_db = 0; my @prev_route; my @next_route; if ( $self->{want_full_routes} ) { @prev_route = $self->parse_route( @{ [ $e->findnodes($xp_prev_route) ] } ); @next_route = $self->parse_route( @{ [ $e->findnodes($xp_next_route) ] } ); } my @line_obj = grep { $_->{identifier} eq $e_line->getAttribute('stateless') } @{ $self->{lines} }; Loading Loading @@ -395,6 +439,8 @@ sub results { sched_date => $date, sched_time => $time, type => $type, prev_route => \@prev_route, next_route => \@next_route, ) ); } Loading
lib/Travel/Status/DE/EFA/Result.pm +12 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,18 @@ sub new { return bless( $ref, $obj ); } sub route_pre { my ($self) = @_; return @{ $self->{prev_route} }; } sub route_post { my ($self) = @_; return @{ $self->{next_route} }; } sub TO_JSON { my ($self) = @_; Loading