summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-12-20 11:10:13 +0100
committerDaniel Friesel <derf@finalrewind.org>2013-12-20 11:10:13 +0100
commitce5dc176beb29b0a0ccc6078ee03f5173eea52ed (patch)
tree285a3ebac32cc7ae2a979ba3c6cf0df21161caf9
parent7b781be7ae6bbe0dfe617e2d6a6f180f64e283a9 (diff)
use Travel::Status::DE::URA for implementation, ::ASEAG for ASEAG URLs
-rwxr-xr-xbin/aseag-m4
-rw-r--r--lib/Travel/Status/DE/ASEAG.pm102
-rw-r--r--lib/Travel/Status/DE/URA.pm14
3 files changed, 114 insertions, 6 deletions
diff --git a/bin/aseag-m b/bin/aseag-m
index bc4541a..ca29fb6 100755
--- a/bin/aseag-m
+++ b/bin/aseag-m
@@ -13,7 +13,7 @@ use DateTime;
use DateTime::Format::Duration;
use Getopt::Long qw(:config no_ignore_case);
use List::Util qw(max);
-use Travel::Status::DE::URA;
+use Travel::Status::DE::ASEAG;
my (@grep_lines);
my $full_route = 0;
@@ -47,7 +47,7 @@ if ( @ARGV != 1 ) {
my ($stop_name) = @ARGV;
-my $status = Travel::Status::DE::URA->new;
+my $status = Travel::Status::DE::ASEAG->new;
sub show_help {
my ($code) = @_;
diff --git a/lib/Travel/Status/DE/ASEAG.pm b/lib/Travel/Status/DE/ASEAG.pm
new file mode 100644
index 0000000..3ef529a
--- /dev/null
+++ b/lib/Travel/Status/DE/ASEAG.pm
@@ -0,0 +1,102 @@
+package Travel::Status::DE::ASEAG;
+
+use strict;
+use warnings;
+use 5.010;
+
+no if $] >= 5.018, warnings => "experimental::smartmatch";
+
+our $VERSION = '0.00';
+
+use parent 'Travel::Status::DE::URA';
+
+sub new {
+ my ( $class, %opt ) = @_;
+
+ $opt{ura_base} = 'http://ivu.aseag.de/interfaces/ura';
+ $opt{ura_version} = '1';
+
+ return $class->SUPER::new(%opt);
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Travel::Status::DE::ASEAG - unofficial ASEAG departure monitor.
+
+=head1 SYNOPSIS
+
+ use Travel::Status::DE::ASEAG;
+
+ my $status = Travel::Status::DE::ASEAG->new(
+ stop => 'Bushof'
+ );
+
+ for my $d ($status->results) {
+ printf(
+ "%s %-5s %25s (in %d min)\n",
+ $d->time, $d->line, $d->destination, $d->countdown
+ );
+ }
+
+=head1 VERSION
+
+version 0.00
+
+=head1 DESCRIPTION
+
+Travel::Status::DE::ASEAG is an unofficial interface to the ASEAG realtime
+departure monitor.
+
+=head1 METHODS
+
+=over
+
+=item my $status = Travel::Status::DE::ASEAG->new(I<%opt>)
+
+Requests the departures as specified by I<opts> and returns a new
+Travel::Status::DE::ASEAG object.
+
+Calls Travel::Status::DE::URA->new with the appropriate B<ura_base> and
+B<ura_version> parameters. All I<opts> are passed on.
+
+See Travel::Status::DE::URA(3pm) for the other methods.
+
+=back
+
+=head1 DIAGNOSTICS
+
+None.
+
+=head1 DEPENDENCIES
+
+=over
+
+=item * Class::Accessor(3pm)
+
+=item * DateTime(3pm)
+
+=item * LWP::UserAgent(3pm)
+
+=item * Travel::Status::DE::URA(3pm)
+
+=back
+
+=head1 BUGS AND LIMITATIONS
+
+Many.
+
+=head1 SEE ALSO
+
+aseag-m(1), Travel::Status::DE::URA(3pm).
+
+=head1 AUTHOR
+
+Copyright (C) 2013 by Daniel Friesel E<lt>derf@finalrewind.orgE<gt>
+
+=head1 LICENSE
+
+This module is licensed under the same terms as Perl itself.
diff --git a/lib/Travel/Status/DE/URA.pm b/lib/Travel/Status/DE/URA.pm
index 8407dcd..5dbaff6 100644
--- a/lib/Travel/Status/DE/URA.pm
+++ b/lib/Travel/Status/DE/URA.pm
@@ -20,12 +20,16 @@ sub new {
my $ua = LWP::UserAgent->new(%opt);
+ if ( not( $opt{ura_base} and $opt{ura_version} ) ) {
+ confess('ura_base and ura_version are mandatory');
+ }
+
my $self = {
- ura_base => $opt{ura_base} // 'http://ivu.aseag.de/interfaces/ura',
- ura_version => $opt{ura_version} // '1',
+ ura_base => $opt{ura_base},
+ ura_version => $opt{ura_version},
full_routes => $opt{full_routes} // 0,
- fuzzy => $opt{fuzzy} // 1,
- hide_past => $opt{hide_past} // 1,
+ fuzzy => $opt{fuzzy} // 1,
+ hide_past => $opt{hide_past} // 1,
stop => $opt{stop},
via => $opt{via},
post => {
@@ -241,6 +245,8 @@ realtime data providers (e.g. ASEAG)
use Travel::Status::DE::URA;
my $status = Travel::Status::DE::URA->new(
+ ura_base => 'http://ivu.aseag.de/interfaces/ura',
+ ura_version => '1',
stop => 'Bushof'
);