From d0f6ffdbfee3b594adf58ce8a83d0564e2181639 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 28 Jan 2022 23:00:23 +0100 Subject: add "meta" dict (referenced / paired stations) --- lib/Travel/Status/DE/IRIS/Stations.pm.PL | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib') diff --git a/lib/Travel/Status/DE/IRIS/Stations.pm.PL b/lib/Travel/Status/DE/IRIS/Stations.pm.PL index 7608f0f..e56b91f 100644 --- a/lib/Travel/Status/DE/IRIS/Stations.pm.PL +++ b/lib/Travel/Status/DE/IRIS/Stations.pm.PL @@ -10,6 +10,9 @@ use JSON; my $json_str = read_file('share/stations.json'); my $stations = JSON->new->utf8->decode($json_str); +my $meta_str = read_file('share/meta.json'); +my $meta = JSON->new->utf8->decode($meta_str); + my $buf = <<'EOF'; package Travel::Status::DE::IRIS::Stations; @@ -64,10 +67,28 @@ for my $station ( @{$stations} ) { $buf .= <<'EOF'; ); +# Automatically generated, see share/meta.json +my $meta = { +EOF + +for my $eva (keys %{$meta}) { + $buf .= sprintf("%s => [%s],\n", + $eva, + join(q{,}, @{$meta->{$eva}}) + ); +} + +$buf .= <<'EOF'; +}; + sub get_stations { return @stations; } +sub get_meta { + return $meta; +} + sub normalize { my ($val) = @_; -- cgit v1.2.3