about summary refs log tree commit diff stats
path: root/ara.pl
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-06-06 16:22:47 +0530
committerAndinus <andinus@nand.sh>2020-06-06 16:22:47 +0530
commit4ae3bf162a68c9819fb68c2e0f46ef29234cece8 (patch)
treed719d8c8786842120ee38c3da12a0eafc843f0dd /ara.pl
parentfd184053ef180d5ad9c825505c2e1f3dec024d65 (diff)
downloadara-4ae3bf162a68c9819fb68c2e0f46ef29234cece8.tar.gz
Switch to Text::ASCIITable for $covid_19_data
Instead of using 2 modules we switch everything to Text:ASCIITable.
Diffstat (limited to 'ara.pl')
-rwxr-xr-xara.pl26
1 files changed, 18 insertions, 8 deletions
diff --git a/ara.pl b/ara.pl
index 9ec1f4d..85856a6 100755
--- a/ara.pl
+++ b/ara.pl
@@ -7,7 +7,6 @@ use feature 'say';
 use Path::Tiny;
 use Time::Moment;
 use JSON::MaybeXS qw( decode_json );
-use Text::Table::Tiny qw( generate_table );
 use Text::ASCIITable;
 
 use OpenBSD::Unveil;
@@ -75,12 +74,23 @@ my $statewise = $json_data->{statewise};
 # Map month number to Months.
 my @months = qw( lol Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
 
-my $covid_19_data = [
-    ['State', 'Confirmed', 'Active', 'Recovered', 'Deaths', 'Last Updated'],
-    ];
+my $covid_19_data = Text::ASCIITable->new();
+$covid_19_data->setCols( 'State',
+                         'Confirmed',
+                         'Active',
+                         'Recovered',
+                         'Deaths',
+                         'Last Updated',
+    );
+
+$covid_19_data->alignCol( { 'Confirmed' => 'left',
+                                'Recovered' => 'left',
+                                'Deaths' => 'left',
+                          } );
+
 
 my $state_notes = Text::ASCIITable->new( { drawRowLine => 1 } );
-$state_notes->setCols( 'State', 'Notes' );
+$state_notes->setCols( qw( State Notes ) );
 $state_notes->setColWidth( 'Notes', 84 );
 
 my $today = Time::Moment
@@ -128,14 +138,14 @@ foreach my $i (0...37) {
         $deaths .= " (+$statewise->[$i]{deltadeaths})";
     }
 
-    push @$covid_19_data, [
+    $covid_19_data->addRow(
         $state,
         $confirmed,
         $statewise->[$i]{active},
         $recovered,
         $deaths,
         $update_info,
-        ];
+        );
 
     $state_notes->addRow(
         $state,
@@ -145,5 +155,5 @@ foreach my $i (0...37) {
 }
 
 # Generate tables.
-say generate_table(rows => $covid_19_data, header_row => 1);
+print $covid_19_data;
 print $state_notes;