Unverified Commit c438b3c4 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Switch from XML to JSON API flavour

parent b8bdca3c
Loading
Loading
Loading
Loading

.mailmap

0 → 100644
+2 −0
Original line number Diff line number Diff line
Birte Kristina Friesel <derf@chaosdorf.de>
Birte Kristina Friesel <derf@finalrewind.org>
+17 −17
Original line number Diff line number Diff line
@@ -21,16 +21,16 @@ Module::Build->new(
		'Carp'                       => 0,
		'Class::Accessor'            => 0,
		'DateTime'                   => 0,
		'DateTime::Format::Strptime' => 0,
		'Getopt::Long'               => 0,
		'JSON'                       => 0,
		'List::Util'                 => 0,
		'LWP::UserAgent'             => 0,
		'LWP::Protocol::https'       => 0,
		'XML::LibXML' => 0,
	},
	sign       => 1,
	meta_merge => {
		resources => {
			repository => 'https://github.com/derf/Travel-Status-DE-VRR'
		}
		resources =>
		  { repository => 'https://github.com/derf/Travel-Status-DE-VRR' }
	},
)->create_build_script();
+10 −0
Original line number Diff line number Diff line
git HEAD
    * Drop XML::LibXML dependency
    * New dependencies: DateTime::Format::Strptime, JSON
    * Switch API language from XML to JSON
    * Rename Travel::Status::DE::EFA::Result to Travel::Status::DE::EFA::Departure
    * EFA: Remove "identified_data" accessor (not supported by JSON backends)
    * Result/Departure: Remove "info" accessor
    * Result/Departure: add "hints" accessor
    * Line: Add "number" accessor

Travel::Status::DE::VRR 2.02 - Sun May 19 2024
    * EFA->new: Deprecate "efa_url" option. Use "service" instead.
      "efa_url" is still supported, just not documented anymore.
+25 −16
Original line number Diff line number Diff line
@@ -198,6 +198,13 @@ sub format_route {
				$stop->name, $stop->platform,
			);
		}
		elsif ( $stop->name ) {
			$output .= sprintf( "               %40s %s\n",
				$stop->name, $stop->platform, );
		}
		else {
			$output .= "?\n";
		}
	}
	return $output;
}
@@ -217,12 +224,12 @@ sub display_result {

	for my $line (@lines) {

		if ( $edata{messages} and length( $line->[5] ) ) {
			$line->[5] =~ tr{\n\x0d}{ }s;
			chomp $line->[5];
		if ( $edata{messages} and $line->[5] and @{ $line->[5] } ) {
			print "\n";
			for my $info_line ( split( qr{\n}, $line->[5] ) ) {
				say "# ${info_line}";
			for my $hint ( @{ $line->[5] } ) {
				$hint =~ tr{\n\x0d}{ }s;
				chomp $hint;
				say "# ${hint}";
			}
		}

@@ -244,7 +251,7 @@ sub show_lines {

	for my $l ( $efa->lines ) {

		if (   ( @grep_lines and none { $l->name eq $_ } @grep_lines )
		if (   ( @grep_lines and none { $l->number eq $_ } @grep_lines )
			or ( @grep_mots and none { $l->mot_name eq $_ } @grep_mots ) )
		{
			next;
@@ -254,8 +261,13 @@ sub show_lines {
			next;
		}

		push( @output,
			[ $l->type, $l->name, $l->direction // q{}, q{}, $l->route // q{} ]
		push(
			@output,
			[
				$l->type, $l->number,
				$l->direction // q{}, q{},
				$l->route // q{}
			]
		);
	}

@@ -288,10 +300,6 @@ sub show_results {
			: $d->datetime->strftime('%H:%M')
		);

		if ( $d->platform_db ) {
			$platform .= ' (DB)';
		}

		if (
			   ( @grep_lines and none { $d->line eq $_ } @grep_lines )
			or ( @grep_mots  and none { $d->mot_name eq $_ } @grep_mots )
@@ -326,12 +334,15 @@ sub show_results {
		}

		my $line = $d->line;
		if ( length($line) > 10 and $d->train_type and $d->train_no ) {
		if (    ( length($line) > 10 or not $line )
			and $d->train_type
			and $d->train_no )
		{
			$line = $d->train_type . ' ' . $d->train_no;
		}

		@output_line
		  = ( $dtime, $platform, $line, q{}, $d->destination, $d->info );
		  = ( $dtime, $platform, $line, q{}, $d->destination, [ $d->hints ] );

		if ( $edata{route} ) {
			$output_line[3]
@@ -615,8 +626,6 @@ None.

=item * Travel::Status::DE::EFA(3pm)

=item * XML::LibXML(3pm)

=back

=head1 BUGS AND LIMITATIONS
+2 −1
Original line number Diff line number Diff line
requires 'Carp';
requires 'Class::Accessor';
requires 'DateTime';
requires 'DateTime::Format::Strptime';
requires 'Getopt::Long';
requires 'JSON';
requires 'List::Util';
requires 'LWP::UserAgent';
requires 'LWP::Protocol::https';
requires 'XML::LibXML';

on test => sub {
	requires 'File::Slurp';
Loading