Commit ba7a15a5 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

rename Travel::Status::DE::IRIS::{Acronyms -> Stations}

parent d1b57191
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
package Travel::Status::DE::IRIS::Acronyms;
package Travel::Status::DE::IRIS::Stations;

use strict;
use warnings;
@@ -9,7 +9,7 @@ use List::MoreUtils qw(firstval);

our $VERSION = '0.00';

my @acronyms = (
my @stations = (

	['XNTH','`t Harde'],
	['YMMBM','6,1/60,3 Bad MGH'],
@@ -15096,21 +15096,21 @@ my @acronyms = (
	['XPZR','Zyrardow'],
);

sub get_acronyms {
	return @acronyms;
sub get_stations {
	return @stations;
}

sub get_acronym_by_name {
sub get_station_by_name {
	my ( $name ) = @_;

	my $nname = lc($name);
	my $actual_match = firstval { $nname eq lc($_->[1]) } @acronyms;
	my $actual_match = firstval { $nname eq lc($_->[1]) } @stations;

	if ($actual_match) {
		return ($actual_match);
	}

	return ( grep { $_->[1] =~ m{$name}i } @acronyms );
	return ( grep { $_->[1] =~ m{$name}i } @stations );
}

1;
+9 −9
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ my $re_line = qr{
}x;

say <<'EOF';
package Travel::Status::DE::IRIS::Acronyms;
package Travel::Status::DE::IRIS::Stations;

use strict;
use warnings;
@@ -24,38 +24,38 @@ use List::MoreUtils qw(firstval);

our $VERSION = '0.00';

my @acronyms = (
my @stations = (
EOF

while (my $line = <STDIN>) {
	chomp $line;

	if ($line =~ $re_line) {
		my ($acronym, $name) = @+{qw{acronym name}};
		my ($station, $name) = @+{qw{acronym name}};
		$name =~ s{'}{\\'}g;

		printf("\t['%s','%s'],\n", $acronym, $name);
		printf("\t['%s','%s'],\n", $station, $name);
	}
}

say <<'EOF';
);

sub get_acronyms {
	return @acronyms;
sub get_stations {
	return @stations;
}

sub get_acronym_by_name {
sub get_station_by_name {
	my ( $name ) = @_;

	my $nname = lc($name);
	my $actual_match = firstval { $nname eq lc($_->[1]) } @acronyms;
	my $actual_match = firstval { $nname eq lc($_->[1]) } @stations;

	if ($actual_match) {
		return ($actual_match);
	}

	return ( grep { $_->[1] =~ m{$name}i } @acronyms );
	return ( grep { $_->[1] =~ m{$name}i } @stations );
}

1;
+1 −1
Original line number Diff line number Diff line
@@ -2,4 +2,4 @@

curl -s http://www.db-netz.de/file/2361656/data/betriebsstellen.pdf \
| pdftotext -raw - - | perl scripts/acronyms.pl \
> lib/Travel/Status/DE/IRIS/Acronyms.pm
> lib/Travel/Status/DE/IRIS/Stations.pm