about summary refs log tree commit diff stats
path: root/ara.pl
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-06-05 23:06:36 +0530
committerAndinus <andinus@nand.sh>2020-06-05 23:06:36 +0530
commit792e9c015017ed5e4c4b7eb4cb2f662b9d2b18f8 (patch)
treee1397037d92e7ff31b797c3801ea146111dde59a /ara.pl
parent97cd205a15d1c405a14560faf26a52f1ac5f289d (diff)
downloadara-792e9c015017ed5e4c4b7eb4cb2f662b9d2b18f8.tar.gz
Use Text::ASCIITable for State Notes
Text::Table::Tiny wasn't good for state notes because they were long &
had characters like '\n'. Text::ASCIITable has nice options to work
with these.
Diffstat (limited to 'ara.pl')
-rwxr-xr-xara.pl14
1 files changed, 7 insertions, 7 deletions
diff --git a/ara.pl b/ara.pl
index 9581417..b115764 100755
--- a/ara.pl
+++ b/ara.pl
@@ -9,6 +9,7 @@ use Path::Tiny;
 use File::Fetch;
 use JSON::MaybeXS qw( decode_json );
 use Text::Table::Tiny qw( generate_table );
+use Text::ASCIITable;
 
 use OpenBSD::Unveil;
 
@@ -80,10 +81,9 @@ my $covid_19_data = [
     ['State', 'Confirmed', 'Active', 'Recovered', 'Deaths', 'Last Updated'],
     ];
 
-my $state_notes = [
-    ['State', 'Notes'],
-    ];
-
+my $state_notes = Text::ASCIITable->new( { drawRowLine => 1 } );
+$state_notes->setCols( 'State', 'Notes' );
+$state_notes->setColWidth( 'Notes', 84 );
 
 my $today = DateTime->now( time_zone => 'Asia/Kolkata' );
 
@@ -136,13 +136,13 @@ foreach my $i (0...37) {
         $update_info,
         ];
 
-    push @$state_notes, [
+    $state_notes->addRow(
         $state,
         $statewise->[$i]{statenotes},
-        ] unless
+        ) unless
         length($statewise->[$i]{statenotes}) eq 0;
 }
 
 # Generate tables.
 say generate_table(rows => $covid_19_data, header_row => 1);
-say generate_table(rows => $state_notes, header_row => 1);
+print $state_notes;