Loading Changelog +6 −0 Original line number Diff line number Diff line git HEAD * Fix bug when receiving no platform numbers from the DB RIS * Result: Add route_timetable accessor containing station names and their corresponding arrival times Travel::Status::DE::DeutscheBahn 0.05 - Tue Aug 09 2011 [Travel::Status::DE::DeutscheBahn] Loading lib/Travel/Status/DE/DeutscheBahn.pm +4 −5 Original line number Diff line number Diff line Loading @@ -117,8 +117,8 @@ sub results { my $xp_info = XML::LibXML::XPathExpression->new('./td[@class="ris"]'); my $re_via = qr{ ^ \s* (.+?) \s* \n \d{1,2}:\d{1,2} ^ \s* (?<stop> .+? ) \s* \n (?<time> \d{1,2}:\d{1,2} ) }mx; if ( defined $self->{results} ) { Loading Loading @@ -164,13 +164,12 @@ sub results { $first = 0; next; } my $stop = $1; if ( $stop =~ m{ [(] Halt \s entf.llt [)] }ox ) { if ( $+{stop} =~ m{ [(] Halt \s entf.llt [)] }ox ) { next; } push( @via, $stop ); push( @via, [ $+{time}, $+{stop} ] ); } push( Loading lib/Travel/Status/DE/DeutscheBahn/Result.pm +13 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ sub origin { sub route { my ($self) = @_; return @{ $self->{route} }; my @stops = map { $_->[1] } @{ $self->{route} }; return @stops; } sub route_interesting { Loading Loading @@ -115,6 +116,12 @@ sub route_interesting { } sub route_timetable { my ($self) = @_; return @{ $self->{route} }; } 1; __END__ Loading Loading @@ -217,6 +224,11 @@ Returns the raw string used to create the route array. Note that canceled stops are filtered from B<route>, but still present in B<route_raw>. =item $result->route_timetable Similar to B<route>. however, this function returns a list of array references of the form C<< [ arrival time, station name ] >>. =item $result->time Returns the arrival/departure time as string in "hh:mm" format. Loading t/20-db.t +17 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ use warnings; use 5.010; use File::Slurp qw(slurp); use Test::More tests => 96; use Test::More tests => 97; BEGIN { use_ok('Travel::Status::DE::DeutscheBahn'); Loading Loading @@ -49,6 +49,22 @@ is_deeply([$departures[8]->route], 'Feldhausen', 'Dorsten', 'Hervest-Dorsten', 'Deuten', 'Rhade', 'Marbeck-Heiden', 'Borken(Westf)'], '9th result: route ok'); is_deeply([$departures[8]->route_timetable], [ ['19:36', 'Essen-Borbeck'], ['19:43', 'Bottrop Hbf'], ['19:50', 'Gladbeck West'], ['19:53', 'Gladbeck-Zweckel'], ['19:56', 'Feldhausen'], ['20:01', 'Dorsten'], ['20:05', 'Hervest-Dorsten'], ['20:10', 'Deuten'], ['20:15', 'Rhade'], ['20:21', 'Marbeck-Heiden'], ['20:27', 'Borken(Westf)'], ], '9th result: route_timetable ok'); is_deeply([$departures[5]->route_interesting(3)], ['Essen-Steele', 'Essen-Steele Ost', 'Bochum'], '6th result: route_interesting(3) ok'); Loading Loading
Changelog +6 −0 Original line number Diff line number Diff line git HEAD * Fix bug when receiving no platform numbers from the DB RIS * Result: Add route_timetable accessor containing station names and their corresponding arrival times Travel::Status::DE::DeutscheBahn 0.05 - Tue Aug 09 2011 [Travel::Status::DE::DeutscheBahn] Loading
lib/Travel/Status/DE/DeutscheBahn.pm +4 −5 Original line number Diff line number Diff line Loading @@ -117,8 +117,8 @@ sub results { my $xp_info = XML::LibXML::XPathExpression->new('./td[@class="ris"]'); my $re_via = qr{ ^ \s* (.+?) \s* \n \d{1,2}:\d{1,2} ^ \s* (?<stop> .+? ) \s* \n (?<time> \d{1,2}:\d{1,2} ) }mx; if ( defined $self->{results} ) { Loading Loading @@ -164,13 +164,12 @@ sub results { $first = 0; next; } my $stop = $1; if ( $stop =~ m{ [(] Halt \s entf.llt [)] }ox ) { if ( $+{stop} =~ m{ [(] Halt \s entf.llt [)] }ox ) { next; } push( @via, $stop ); push( @via, [ $+{time}, $+{stop} ] ); } push( Loading
lib/Travel/Status/DE/DeutscheBahn/Result.pm +13 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ sub origin { sub route { my ($self) = @_; return @{ $self->{route} }; my @stops = map { $_->[1] } @{ $self->{route} }; return @stops; } sub route_interesting { Loading Loading @@ -115,6 +116,12 @@ sub route_interesting { } sub route_timetable { my ($self) = @_; return @{ $self->{route} }; } 1; __END__ Loading Loading @@ -217,6 +224,11 @@ Returns the raw string used to create the route array. Note that canceled stops are filtered from B<route>, but still present in B<route_raw>. =item $result->route_timetable Similar to B<route>. however, this function returns a list of array references of the form C<< [ arrival time, station name ] >>. =item $result->time Returns the arrival/departure time as string in "hh:mm" format. Loading
t/20-db.t +17 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ use warnings; use 5.010; use File::Slurp qw(slurp); use Test::More tests => 96; use Test::More tests => 97; BEGIN { use_ok('Travel::Status::DE::DeutscheBahn'); Loading Loading @@ -49,6 +49,22 @@ is_deeply([$departures[8]->route], 'Feldhausen', 'Dorsten', 'Hervest-Dorsten', 'Deuten', 'Rhade', 'Marbeck-Heiden', 'Borken(Westf)'], '9th result: route ok'); is_deeply([$departures[8]->route_timetable], [ ['19:36', 'Essen-Borbeck'], ['19:43', 'Bottrop Hbf'], ['19:50', 'Gladbeck West'], ['19:53', 'Gladbeck-Zweckel'], ['19:56', 'Feldhausen'], ['20:01', 'Dorsten'], ['20:05', 'Hervest-Dorsten'], ['20:10', 'Deuten'], ['20:15', 'Rhade'], ['20:21', 'Marbeck-Heiden'], ['20:27', 'Borken(Westf)'], ], '9th result: route_timetable ok'); is_deeply([$departures[5]->route_interesting(3)], ['Essen-Steele', 'Essen-Steele Ost', 'Bochum'], '6th result: route_interesting(3) ok'); Loading