diff options
author | Daniel Friesel <derf@finalrewind.org> | 2013-12-11 00:25:45 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2013-12-11 00:25:45 +0100 |
commit | 760fdc53ac4ba5e34b0ea6fe659dc81b462adfd1 (patch) | |
tree | 2477a7130491984569f6b4bc0c291fc35ef155b9 | |
parent | cfe2fae34e3bfe545a7576918aed0556e468a54c (diff) |
perltidy
-rwxr-xr-x | bin/aseag-m | 29 | ||||
-rw-r--r-- | lib/Travel/Status/DE/ASEAG.pm | 68 | ||||
-rw-r--r-- | lib/Travel/Status/DE/ASEAG/Result.pm | 3 |
3 files changed, 50 insertions, 50 deletions
diff --git a/bin/aseag-m b/bin/aseag-m index f4ca96b..6361312 100755 --- a/bin/aseag-m +++ b/bin/aseag-m @@ -13,12 +13,12 @@ use Getopt::Long qw(:config no_ignore_case); use List::Util qw(max); use Travel::Status::DE::ASEAG; -my ( @grep_lines ); +my (@grep_lines); GetOptions( - 'h|help' => sub { show_help(0) }, - 'l|line=s@' => \@grep_lines, - 'V|version' => \&show_version, + 'h|help' => sub { show_help(0) }, + 'l|line=s@' => \@grep_lines, + 'V|version' => \&show_version, ) or show_help(1); @@ -27,19 +27,16 @@ if ( @ARGV != 1 ) { } # --line=foo,bar support -@grep_lines = split( qr{,}, join( q{,}, @grep_lines ) ); +@grep_lines = split( qr{,}, join( q{,}, @grep_lines ) ); -my ( $stop_name ) = @ARGV; +my ($stop_name) = @ARGV; -my $status = Travel::Status::DE::ASEAG->new( - name => $stop_name, -); +my $status = Travel::Status::DE::ASEAG->new( name => $stop_name, ); sub show_help { my ($code) = @_; - print "Usage: aseag-m <stop name>\n" - . "See also: man aseag-m\n"; + print "Usage: aseag-m <stop name>\n" . "See also: man aseag-m\n"; exit $code; } @@ -79,17 +76,13 @@ sub show_results { for my $d ( $status->results ) { - my $dtime = $d->time; + my $dtime = $d->time; - if ( - ( @grep_lines and not( $d->line ~~ \@grep_lines ) ) - ) - { + if ( ( @grep_lines and not( $d->line ~~ \@grep_lines ) ) ) { next; } - push( @output, - [ $dtime, $d->line, $d->destination ] ); + push( @output, [ $dtime, $d->line, $d->destination ] ); } display_result(@output); diff --git a/lib/Travel/Status/DE/ASEAG.pm b/lib/Travel/Status/DE/ASEAG.pm index 8311ad6..21cd992 100644 --- a/lib/Travel/Status/DE/ASEAG.pm +++ b/lib/Travel/Status/DE/ASEAG.pm @@ -17,15 +17,15 @@ use LWP::UserAgent; sub new { my ( $class, %opt ) = @_; - my $ua = LWP::UserAgent->new(%opt); + my $ua = LWP::UserAgent->new(%opt); my $self = { fuzzy => $opt{fuzzy} // 1, - stop => $opt{name}, - post => { + stop => $opt{name}, + post => { ReturnList => - 'lineid,linename,directionid,destinationtext,vehicleid,' - .'tripid,estimatedtime,stopid,stoppointname' + 'lineid,linename,directionid,destinationtext,vehicleid,' + . 'tripid,estimatedtime,stopid,stoppointname' }, }; @@ -33,8 +33,8 @@ sub new { $ua->env_proxy; - my $response - = $ua->post( 'http://ivu.aseag.de/interfaces/ura/instant_V1', $self->{post} ); + my $response = $ua->post( 'http://ivu.aseag.de/interfaces/ura/instant_V1', + $self->{post} ); if ( $response->is_error ) { $self->{errstr} = $response->status_line; @@ -80,14 +80,14 @@ sub sprintf_time { } sub is_my_stop { - my ($self, $stop) = @_; + my ( $self, $stop ) = @_; my $my_stop = $self->{stop}; - if ($self->{fuzzy}) { - return ($stop =~ m{ $my_stop }ix ? 1 : 0); + if ( $self->{fuzzy} ) { + return ( $stop =~ m{ $my_stop }ix ? 1 : 0 ); } else { - return ($stop eq $my_stop); + return ( $stop eq $my_stop ); } } @@ -97,41 +97,49 @@ sub results { my $dt_now = DateTime->now( time_zone => 'Europe/Berlin' ); - for my $dep (split(/\r\n/, $self->{raw})) { + for my $dep ( split( /\r\n/, $self->{raw} ) ) { $dep =~ s{^\[}{}; $dep =~ s{\]$}{}; - my ($u1, $stopname, $stopid, $lineid, $linename, $u2, $dest, - $vehicleid, $tripid, $timestamp) = split(/"?,"?/, $dep); + my ( + $u1, $stopname, $stopid, $lineid, $linename, + $u2, $dest, $vehicleid, $tripid, $timestamp + ) = split( /"?,"?/, $dep ); # version information - if ($u1 == 4) { + if ( $u1 == 4 ) { next; } - if ($self->{stop} and not $self->is_my_stop($stopname)) { + if ( $self->{stop} and not $self->is_my_stop($stopname) ) { next; } - if (not $timestamp) { + if ( not $timestamp ) { cluck("departure element without timestamp: $dep"); next; } my $dt_dep = DateTime->from_epoch( - epoch => $timestamp / 1000, - time_zone => 'Europe/Berlin' ); - - push(@results, Travel::Status::DE::ASEAG::Result->new( - date => $dt_dep->strftime('%d.%m.%Y'), - time => $dt_dep->strftime('%H:%M:%S'), - datetime => $dt_dep, - line => $linename, - line_id => $lineid, - destination => decode( 'UTF-8', $dest ), - countdown => $dt_dep->subtract_datetime($dt_now)->in_units('minutes'), - countdown_sec => $dt_dep->subtract_datetime($dt_now)->in_units('seconds'), - )); + epoch => $timestamp / 1000, + time_zone => 'Europe/Berlin' + ); + + push( + @results, + Travel::Status::DE::ASEAG::Result->new( + date => $dt_dep->strftime('%d.%m.%Y'), + time => $dt_dep->strftime('%H:%M:%S'), + datetime => $dt_dep, + line => $linename, + line_id => $lineid, + destination => decode( 'UTF-8', $dest ), + countdown => + $dt_dep->subtract_datetime($dt_now)->in_units('minutes'), + countdown_sec => + $dt_dep->subtract_datetime($dt_now)->in_units('seconds'), + ) + ); } @results = map { $_->[0] } diff --git a/lib/Travel/Status/DE/ASEAG/Result.pm b/lib/Travel/Status/DE/ASEAG/Result.pm index 668ba1d..05045b1 100644 --- a/lib/Travel/Status/DE/ASEAG/Result.pm +++ b/lib/Travel/Status/DE/ASEAG/Result.pm @@ -9,8 +9,7 @@ use parent 'Class::Accessor'; our $VERSION = '0.00'; Travel::Status::DE::ASEAG::Result->mk_ro_accessors( - qw(countdown countdown_sec date datetime destination line line_id time) -); + qw(countdown countdown_sec date datetime destination line line_id time)); sub new { my ( $obj, %conf ) = @_; |