diff options
author | Daniel Friesel <derf@finalrewind.org> | 2014-01-18 22:22:25 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2014-01-18 22:22:25 +0100 |
commit | b8fd2abe65a1ff299307e06d576ae3b9cc5b8af2 (patch) | |
tree | ba07a291bf944564f2487ddd9718c9b0f1c7a67b | |
parent | eccf8ca2b1d6625a2d17d12ab2f0dbc5d49fac75 (diff) |
add efa-url support to efa script
-rwxr-xr-x | bin/efa | 22 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/EFA.pm | 12 |
2 files changed, 23 insertions, 11 deletions
@@ -11,21 +11,23 @@ no if $] >= 5.018, warnings => "experimental::smartmatch"; use utf8; use Encode qw(decode); -use Travel::Routing::DE::VRR; +use Travel::Routing::DE::EFA; use Exception::Class; use Getopt::Long qw/:config no_ignore_case/; our $VERSION = '2.04'; my $ignore_info = 'Fahrradmitnahme'; my $efa; +my $efa_url = 'http://efa.vrr.de/vrr/XSLT_TRIP_REQUEST2'; my ( @from, @to, @via, $from_type, $to_type, $via_type ); my $opt = { + 'efa-url' => \$efa_url, 'help' => sub { show_help(0) }, 'ignore-info' => \$ignore_info, 'from' => \@from, 'to' => \@to, - 'version' => sub { say "efa version $VERSION"; exit 0 }, - 'via' => \@via, + 'version' => sub { say "efa version $VERSION"; exit 0 }, + 'via' => \@via, }; binmode( STDOUT, ':encoding(utf-8)' ); @@ -146,6 +148,7 @@ GetOptions( bike|b date|d=s depart=s + efa-url|u=s exclude|e=s@ extended-info|E from=s@{2} @@ -199,7 +202,9 @@ if ( defined $opt->{'ignore-info'} and length( $opt->{'ignore-info'} ) == 0 ) { } $efa = eval { - Travel::Routing::DE::VRR->new( + Travel::Routing::DE::EFA->new( + efa_url => $efa_url, + origin => [ @from, $from_type ], destination => [ @to, $to_type ], via => ( @via ? [ @via, $via_type ] : undef ), @@ -381,6 +386,13 @@ Ignore additional information matching I<regex> (default: /Fahrradmitnahme/) If I<regex> is not supplied, removes the default regex (-E<gt> nothing will be ignored) +=item B<-u>|B<--efa-url> I<url> + +URL to the EFA entry point, defaults to +L<http://efa.vrr.de/vrr/XSLT_TRIP_REQUEST2>. Depending on your location, some +I<url>s may contain more specific data than others. See +Travel::Routing::DE::EFA(3pm) for alternatives. + =item B<--timeout> I<seconds> Set timeout for HTTP requests. Default: 60 seconds. @@ -407,7 +419,7 @@ Print version information 3 efa.vrr.de did not return any parsable data 4 efa.vrr.de error: ambiguous input 5 efa.vrr.de error: no connections found - 10 Unknown Travel::Routing::DE::VRR error + 10 Unknown Travel::Routing::DE::EFA error 255 Other internal error =head1 CONFIGURATION diff --git a/lib/Travel/Routing/DE/EFA.pm b/lib/Travel/Routing/DE/EFA.pm index 2da6e2e..9ccf2ff 100644 --- a/lib/Travel/Routing/DE/EFA.pm +++ b/lib/Travel/Routing/DE/EFA.pm @@ -392,7 +392,7 @@ sub new { bless( $ref, $obj ); - if (not $ref->{config}->{efa_url}) { + if ( not $ref->{config}->{efa_url} ) { Travel::Routing::DE::EFA::Exception::Setup->throw( option => 'efa_url', error => 'must be set' @@ -426,8 +426,8 @@ sub submit { $self->{ua} = LWP::UserAgent->new(%conf); $self->{ua}->env_proxy; - my $response = $self->{ua} - ->post( $self->{config}->{efa_url}, $self->{post} ); + my $response + = $self->{ua}->post( $self->{config}->{efa_url}, $self->{post} ); if ( $response->is_error ) { Travel::Routing::DE::EFA::Exception::Net->throw( @@ -737,11 +737,11 @@ Known URLs are: =over -=item * L<http://212.114.197.7/vgnExt_oeffi/XML_DM_REQUEST> (Verkehrsverbund GroE<szlig>raum NE<uuml>rnberg) +=item * L<http://212.114.197.7/vgnExt_oeffi/XML_TRIP_REQUEST2> (Verkehrsverbund GroE<szlig>raum NE<uuml>rnberg) -=item * L<http://efa.vrr.de/vrr/XSLT_DM_REQUEST> (Verkehrsverbund Rhein-Ruhr) +=item * L<http://efa.vrr.de/vrr/XSLT_TRIP_REQUEST2> (Verkehrsverbund Rhein-Ruhr) -=item * L<http://www2.vvs.de/vvs/XSLT_DM_REQUEST> (Verkehrsverbund Stuttgart) +=item * L<http://www2.vvs.de/vvs/XSLT_TRIP_REQUEST2> (Verkehrsverbund Stuttgart) =back |