Shlomi Fish avatar Shlomi Fish committed e4fc8ea

Implement support for the s delay.

Comments (0)

Files changed (4)

App-Countdown/Changes

 Revision history for App-Countdown
 
+0.3.0   Sat 31 Aug 18:01:02 IDT 2013
+        * Implement support for the "s" delay.
+            - it kept tripping me up, so I added it.
+
 0.2.0   Thu 15 Nov 16:21:16 IST 2012
         * Add --version, --help, and --man flags.
             - Thanks to Steven Haryanto from

App-Countdown/bin/countdown

     countdown [number of seconds]
     countdown [minutes]m
     countdown [hours]h
+    countdown [seconds]s
 
 =head1 OPTIONS
 

App-Countdown/lib/App/Countdown.pm

 sub _calc_delay {
     my ($self, $delay_spec) = @_;
 
-    if (my ($n, $qualifier) = $delay_spec =~ /\A((?:[1-9][0-9]*(?:\.\d*)?)|(?:0\.\d+))([mh]?)\z/)
+    if (my ($n, $qualifier) = $delay_spec =~ /\A((?:[1-9][0-9]*(?:\.\d*)?)|(?:0\.\d+))([mhs]?)\z/)
     {
         return int($n * ($qualifier eq 'h'
                 ? (60 * 60)
     }
     else
     {
-        die "Invalid delay. Must be a positive and possibly fractional number, possibly followed by m or h";
+        die "Invalid delay. Must be a positive and possibly fractional number, possibly followed by s, m, or h";
     }
 }
 

App-Countdown/t/unit-calc-delay.t

 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 10;
 
 use App::Countdown;
 
 
     # TEST
     is ($obj->_calc_delay('0.5m'), 30, "_calc_delay(0.5m) == 30 (leading zero)");
+
+    # TEST
+    is ($obj->_calc_delay('90s'), 90, "_calc_delay(90s) == 90 (seconds)");
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.