diff options
-rw-r--r-- | Changelog | 4 | ||||
-rwxr-xr-x | bin/efa-m | 13 | ||||
-rw-r--r-- | lib/Travel/Status/DE/EFA.pm | 45 |
3 files changed, 52 insertions, 10 deletions
@@ -9,8 +9,8 @@ git HEAD * Stop: Add "place", "full_name" and "occupancy" accessors * Stop: Remove "name_suf" accessor; use "name" instead * Line: Add "number" accessor - * EFA: Remove "get_efa_urls" and "get_service" functions; use the newly - introduced Travel::Status::DE::EFA::Services package instead. + * EFA: Remove static "get_efa_urls" function; use "get_service_ids" instead + * EFA: Add static "get_service_ids" function * efa-m: -Oa, -Ob, -Of: show per-stop occupancy, if available Travel::Status::DE::VRR 2.02 - Sun May 19 2024 @@ -12,7 +12,6 @@ use Encode qw(decode); use Getopt::Long qw(:config no_ignore_case bundling); use List::Util qw(first max none); use Travel::Status::DE::EFA; -use Travel::Status::DE::EFA::Services; my $service = 'VRR'; my $efa_url; @@ -113,7 +112,7 @@ if ($efa_url) { $service = undef; } elsif ($service) { - my $service_ref = Travel::Status::DE::EFA::Services::get_service($service); + my $service_ref = Travel::Status::DE::EFA::get_service($service); if ( not $service_ref ) { printf STDERR ( "Error: Unknown service '%s'. See 'efa-m --list' for a " @@ -157,9 +156,8 @@ sub show_help { sub show_services { printf( "%-45s %-14s %s\n\n", 'service', 'abbr. (-s)', 'url (-u)' ); - for my $shortname ( Travel::Status::DE::EFA::Services::get_service_ids() ) { - my $service - = Travel::Status::DE::EFA::Services::get_service($shortname); + for my $shortname ( Travel::Status::DE::EFA::get_service_ids() ) { + my $service = Travel::Status::DE::EFA::get_service($shortname); printf( "%-45s %-14s %s\n", $service->{name}, $shortname, $service->{url} ); } @@ -441,14 +439,13 @@ sub show_results { } if ( $discover or $discover_and_print ) { - for my $shortname ( Travel::Status::DE::EFA::Services::get_service_ids() ) { + for my $shortname ( Travel::Status::DE::EFA::get_service_ids() ) { $efa = new_efa($shortname); if ( $efa and not $efa->errstr ) { if ($discover_and_print) { last; } - my $service_ref - = Travel::Status::DE::EFA::Services::get_service($shortname); + my $service_ref = Travel::Status::DE::EFA::get_service($shortname); printf( "%s / %s (%s)\n -> efa-m -s %s %s\n\n", $service_ref->{name}, $shortname, $service_ref->{url}, diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index b95ff41..6aa505b 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -404,6 +404,16 @@ sub result { return Travel::Status::DE::EFA::Trip->new( json => $self->{response} ); } +# static +sub get_service_ids { + return Travel::Status::DE::EFA::Services::get_service_ids(@_); +} + +# static +sub get_service { + return Travel::Status::DE::EFA::Services::get_service(@_); +} + 1; __END__ @@ -547,6 +557,41 @@ nothing (undef / empty list) otherwise. Returns a list of Travel::Status::DE::EFA::Departure(3pm) objects, each one describing one departure. +=item Travel::Status::DE::EFA::get_service_ids() + +Returns the list of supported services (backends). + +=item Travel::Status::DE::EFA::get_service(I<service>) + +Returns a hashref describing the requested I<service> ID with the following keys. + +=over + +=item B<name> => I<string> + +Provider name, e.g. Verkehrsverbund Oberelbe. + +=item B<url> => I<string> + +Backend base URL. + +=item B<homepage> => I<string> (optional) + +Provider homepage. + +=item B<languages> => I<arrayref> (optional) + +Supportde languages, e.g. de, en. + +=item B<coverage> => I<hashref> + +Area in which the service provides near-optimal coverage. Typically, this +means a (nearly) complete list of departures and real-time data. The +hashref contains two optional keys: B<area> (GeoJSON) and B<regions> (list of +strings, e.g. "DE" or "CH-BE"). + +=back + =back =head1 DIAGNOSTICS |