r22207 - in /branches/upstream/libscriptalicious-perl/current: ./ lib/ t/ t/missing/ t/missing/Pod/

eloy at users.alioth.debian.org eloy at users.alioth.debian.org
Fri Jun 27 08:44:41 UTC 2008


Author: eloy
Date: Fri Jun 27 08:44:41 2008
New Revision: 22207

URL: http://svn.debian.org/wsvn/?sc=1&rev=22207
Log:
[svn-upgrade] Integrating new upstream version, libscriptalicious-perl (1.15)

Added:
    branches/upstream/libscriptalicious-perl/current/MANIFEST.SKIP
    branches/upstream/libscriptalicious-perl/current/t/06-anydump.t
    branches/upstream/libscriptalicious-perl/current/t/07-tsay.t
    branches/upstream/libscriptalicious-perl/current/t/08-unit.t
    branches/upstream/libscriptalicious-perl/current/t/09-noyaml.t
    branches/upstream/libscriptalicious-perl/current/t/dump.pl
    branches/upstream/libscriptalicious-perl/current/t/missing/
    branches/upstream/libscriptalicious-perl/current/t/missing/Pod/
    branches/upstream/libscriptalicious-perl/current/t/missing/Pod/Constants.pm
    branches/upstream/libscriptalicious-perl/current/t/missing/Template.pm
    branches/upstream/libscriptalicious-perl/current/t/missing/YAML.pm
    branches/upstream/libscriptalicious-perl/current/t/tsay.pl
Removed:
    branches/upstream/libscriptalicious-perl/current/Build.PL
Modified:
    branches/upstream/libscriptalicious-perl/current/Changes.pod
    branches/upstream/libscriptalicious-perl/current/MANIFEST
    branches/upstream/libscriptalicious-perl/current/META.yml
    branches/upstream/libscriptalicious-perl/current/Makefile.PL
    branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm
    branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod
    branches/upstream/libscriptalicious-perl/current/t/01-mmmdelicious.t
    branches/upstream/libscriptalicious-perl/current/t/02-script.t
    branches/upstream/libscriptalicious-perl/current/t/03-yaml.t
    branches/upstream/libscriptalicious-perl/current/t/04-fork.t

Modified: branches/upstream/libscriptalicious-perl/current/Changes.pod
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/Changes.pod?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/Changes.pod (original)
+++ branches/upstream/libscriptalicious-perl/current/Changes.pod Fri Jun 27 08:44:41 2008
@@ -1,11 +1,82 @@
 
 =head1 WHATS NEW IN SCRIPTALICIOUS
+
+=head2 VERSION 1.15
+
+=over
+
+=item Add missing copyright notices and license.
+
+Gah, sorry about this.  Note that it is a retrospective license, so
+you don't need to 'upgrade' to this version to copy the software.
+
+=item Clear PERL5OPT before invoking $^X in tests
+
+To hopefully resolve some false failures
+
+=back
+
+=head2 VERSION 1.14
+
+=over
+
+=item 5.6.x compat: fix missed instance of unquoted filehandle in test suite
+
+=back
+
+=head2 VERSION 1.13
+
+=over
+
+=item 5.6.x compat: don't use readline FH; use <FH> instead
+
+=item Don't die if getconf is called without YAML installed; warn instead
+
+=item Make YAML config test conditional on YAML being installed
+
+=item Fix incorrectly written e-mail address in Makefile.PL
+
+=item Remove TODO file; these features have been added!
+
+=back
+
+=head2 VERSION 1.12
+
+=over
+
+=item Add getopt_lenient()
+
+=item Add time_unit() function
+
+=item Use time_unit instead of sci_unit in show_elapsed/show_delta
+
+=item Fix test that was still testing for µ
+
+=back
+
+=head2 VERSION 1.11
+
+=over
+
+=item Drop C<Module::Build> dependency
+
+Go back to C<ExtUtils::MakeMaker>.
+
+=item Fix various problems with prompt_*
+
+=item Add C<hush_exec> and C<unhush_exec> functions
+
+=item Make C<getopt()> optional for getting verbosity right
+
+=item Functions don't clobber $_ (Gerard Goosen)
+
+=back
 
 =head2 VERSION 1.10
 
 Add prompt_file from an earlier branch.
 
-Fix Build.PL so a compatibility Makefile.PL is generated.
+Fix F<Build.PL> so a compatibility Makefile.PL is generated.
 
 =head2 VERSION 1.09
 

Modified: branches/upstream/libscriptalicious-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/MANIFEST?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/MANIFEST (original)
+++ branches/upstream/libscriptalicious-perl/current/MANIFEST Fri Jun 27 08:44:41 2008
@@ -1,19 +1,28 @@
-MANIFEST
+Changes.pod
+lib/Scriptalicious.pm
+lib/Scriptalicious.pod
+Makefile.PL
+MANIFEST			This list of files
+MANIFEST.SKIP
 README
-Changes.pod
-META.yml
-lib/Scriptalicious.pm		Mmm, Scriptalicious
-lib/Scriptalicious.pod		POD's what it's all about, baby!
 t/01-mmmdelicious.t
 t/02-script.t
 t/03-yaml.t
 t/04-fork.t
 t/05-prompt.t
-t/pu.pl
+t/06-anydump.t
+t/07-tsay.t
+t/08-unit.t
+t/09-noyaml.t
+t/dump.pl
+t/eg.conf
 t/fork.pl
 t/loopback.pl
+t/missing/Pod/Constants.pm
+t/missing/Template.pm
+t/missing/YAML.pm
 t/prompter.pl
+t/pu.pl
+t/tsay.pl
 t/Util.pm
-t/eg.conf
-Build.PL
-Makefile.PL
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libscriptalicious-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/MANIFEST.SKIP?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libscriptalicious-perl/current/MANIFEST.SKIP Fri Jun 27 08:44:41 2008
@@ -1,0 +1,8 @@
+.git
+.gitignore
+.*.tar.gz
+MANIFEST.bak
+Makefile(.bak)?$
+~$
+^blib
+pm_to_blib

Modified: branches/upstream/libscriptalicious-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/META.yml?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/META.yml (original)
+++ branches/upstream/libscriptalicious-perl/current/META.yml Fri Jun 27 08:44:41 2008
@@ -1,24 +1,15 @@
----
-name: Scriptalicious
-version: 1.10
-author: ~
-abstract: ~
-license: perl
-recommends:
-  Term::ReadKey: 0
-  Text::Wrap: 0
-  Time::HiRes: 0
-  YAML: 0
-build_requires:
-  Test::More: 0
-provides:
-  Scriptalicious:
-    file: lib/Scriptalicious.pm
-    version: 1.10
-  Scriptalicious::DataLoad:
-    file: lib/Scriptalicious.pm
-    version: 1.10
-  Scriptalicious::Template:
-    file: lib/Scriptalicious.pm
-    version: 1.10
-generated_by: Module::Build version 0.2611
+--- #YAML:1.0
+name:                Scriptalicious
+version:             1.15
+abstract:            Make scripts more delicious to SysAdmins
+license:             ~
+author:              
+    - Sam Vilain <samv at cpan.org>
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
+    Term::ReadKey:                 0
+    Test::More:                    0
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: branches/upstream/libscriptalicious-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/Makefile.PL?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/Makefile.PL (original)
+++ branches/upstream/libscriptalicious-perl/current/Makefile.PL Fri Jun 27 08:44:41 2008
@@ -1,31 +1,27 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.03
-    
-    unless (eval "use Module::Build::Compat 0.02; 1" ) {
-      print "This module requires Module::Build to install itself.\n";
-      
-      require ExtUtils::MakeMaker;
-      my $yn = ExtUtils::MakeMaker::prompt
-	('  Install Module::Build now from CPAN?', 'y');
-      
-      unless ($yn =~ /^y/i) {
-	die " *** Cannot install without Module::Build.  Exiting ...\n";
-      }
-      
-      require Cwd;
-      require File::Spec;
-      require CPAN;
-      
-      # Save this 'cause CPAN will chdir all over the place.
-      my $cwd = Cwd::cwd();
-      my $makefile = File::Spec->rel2abs($0);
-      
-      CPAN::Shell->install('Module::Build::Compat')
-	or die " *** Cannot install without Module::Build.  Exiting ...\n";
-      
-      chdir $cwd or die "Cannot chdir() back to $cwd: $!";
+#!/usr/bin/perl
+#
+use ExtUtils::MakeMaker;
+# See perldoc Module::Build for details of how this works
+
+my @recommends = qw(Text::Wrap Time::HiRes YAML Pod::Constants);
+
+for my $module ( @recommends ) {
+    eval "use $module";
+    if ( $@ ) {
+	warn "Failed to load optional dependency $module ($@)";
     }
-    eval "use Module::Build::Compat 0.02; 1" or die $@;
-    use lib '_build/lib';
-    Module::Build::Compat->run_build_pl(args => \@ARGV);
-    require Module::Build;
-    Module::Build::Compat->write_makefile(build_class => 'Module::Build');
+}
+
+WriteMakefile
+    ( NAME     => 'Scriptalicious',
+      VERSION_FROM => "lib/Scriptalicious.pm",
+      ( ( $] >= 5.005 ) ?
+	( ABSTRACT => "Make scripts more delicious to SysAdmins",
+	  AUTHOR     => "Sam Vilain <samv\@cpan.org>",
+	) : () ),
+      PREREQ_PM => {
+		    'Test::More' => 0,
+		    'Term::ReadKey' => 0,
+		   },
+      NO_META => 0,
+    );

Modified: branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm (original)
+++ branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm Fri Jun 27 08:44:41 2008
@@ -1,3 +1,11 @@
+
+# Copyright 2005-2008, Sam Vilain.  All rights reserved.  This program
+# is free software; you can use it and/or distribute it under the same
+# terms as Perl itself; either the latest stable release of Perl when
+# the module was written, or any subsequent stable release.
+#
+# Please note that this applies retrospectively to all Scriptalicious
+# releases; apologies for the lack of an explicit license.
 
 package Scriptalicious;
 
@@ -6,7 +14,7 @@
 use warnings;
 use Carp qw(croak);
 
-our $VERSION = "1.10";
+our $VERSION = "1.15";
 
 use Getopt::Long;
 use base qw(Exporter);
@@ -19,16 +27,19 @@
 		     start_timer show_delta show_elapsed getconf
 		     getconf_f sci_unit prompt_for prompt_passwd
 		     prompt_yn prompt_Yn prompt_yN prompt_string
+		     prompt_nY prompt_Ny prompt_ny
 		     prompt_int tsay anydump prompt_regex prompt_sub
-		     prompt_file
+		     prompt_file hush_exec unhush_exec
+		     getopt_lenient time_unit
 		    );
 }
 
 # define this in subclasses where appropriate
 sub __package__ { __PACKAGE__ }
 
-our ($VERBOSE, $closure);
+our ($VERBOSE, $closure, $SHOW_CMD_VERBOSE, $gotconf);
 $VERBOSE = 0;
+$SHOW_CMD_VERBOSE = 1;
 
 #---------------------------------------------------------------------
 #  parse import arguments and export symbols
@@ -62,10 +73,10 @@
 
 END { $closure->() if $closure }
 
-sub getopt {
-
+sub getopt_lenient {
     local($closure) = \&show_usage;
 
+    $gotconf = 1;
     Getopt::Long::GetOptions
 	    (
 	     'help|h' => \&show_help,
@@ -81,18 +92,28 @@
 
     shift @ARGV, return if $#ARGV >= 0 and $ARGV[0] eq "--";
 
+}
+
+sub getopt {
+    local($closure) = \&show_usage;
+
+    getopt_lenient(@_);
+
     abort("unrecognised option: $ARGV[0]")
 	if $#ARGV >= 0 and $ARGV[0] =~ m/^-/;
 }
 
-sub say { print "$PROGNAME: @_\n" unless $VERBOSE < 0 }
+sub say { _autoconf() unless $gotconf;
+	  print "$PROGNAME: @_\n" unless $VERBOSE < 0 }
 sub mutter { say @_ if $VERBOSE }
 sub whisper { say @_ if $VERBOSE > 1 }
-sub _err_say { print STDERR "$PROGNAME: @_\n" }
+sub _err_say { _autoconf() unless $gotconf;
+	       print STDERR "$PROGNAME: @_\n" }
 sub abort { _err_say "aborting: @_"; &show_usage; }
 sub moan { _err_say "warning: @_" }
 sub protest { _err_say "error: @_" }
 sub barf { if($^S){die @_}else{ _err_say "ERROR: @_"; exit(1); } }
+sub _autoconf { getopt_lenient( eval{ my @x = getconf(@_); @x } ) }
 
 #---------------------------------------------------------------------
 #  helpers for running commands and/or capturing their output
@@ -108,6 +129,15 @@
         s/[\0-\031"\s\177-\377]/$map{$&}/eg;
         $_ = "\"$_\"";
     }; $_ } map { $_ } @_);
+}
+
+our @SHOW_CMD_VERBOSE;
+sub hush_exec {
+    push @SHOW_CMD_VERBOSE, $SHOW_CMD_VERBOSE;
+    $SHOW_CMD_VERBOSE=2;
+}
+sub unhush_exec {
+    $SHOW_CMD_VERBOSE = pop @SHOW_CMD_VERBOSE;
 }
 
 our @last_cmd;
@@ -122,7 +152,7 @@
          (($? >> 8)
           ? "exited with error code ".($?>>8)
           : "killed by signal $?")
-         .(($VERBOSE >= 1 or $next_cmd_no_hide) ? ""
+         .(($VERBOSE >= $SHOW_CMD_VERBOSE or $next_cmd_no_hide) ? ""
            : (($start != 0
 	       ? "\nlast lines of output:\n"
 	       : "\nprogram output:\n")
@@ -136,7 +166,7 @@
 sub do_fork {
     @output = ();
     if (not $next_cmd_capture and
-	( $VERBOSE >= 1 or $next_cmd_no_hide )) {
+	( $VERBOSE >= $SHOW_CMD_VERBOSE or $next_cmd_no_hide )) {
         return fork()
     } else {
         my $pid = open CHILD, "-|";
@@ -151,11 +181,11 @@
     my $pid = shift;
 
     if (not $next_cmd_capture and
-	($VERBOSE >= 1 or $next_cmd_no_hide)) {
+	($VERBOSE >= $SHOW_CMD_VERBOSE or $next_cmd_no_hide)) {
         waitpid($pid, 0);
     } else {
-        while (<CHILD>) {
-            push @output, $_;
+        while (my $line = <CHILD>) {
+            push @output, $line;
         }
         close CHILD;
     }
@@ -181,12 +211,14 @@
 	$fd_desc .= ($fd_desc ? ", " : "") . "fd$fd=$mode$fds{$fd}";
     }
     @last_cmd = @_;
-    mutter("running `".shellquote(@last_cmd)."'"
-	   .($next_cmd_capture
-	     ? " (captured)"
-	     : "")
-	   .($fd_desc?"($fd_desc)":"")
-	  ) unless ref($_[0]);
+    if ( $VERBOSE >= $SHOW_CMD_VERBOSE ) {
+	say("running `".shellquote(@last_cmd)."'"
+	    .($next_cmd_capture
+	      ? " (captured)"
+	      : "")
+	    .($fd_desc?"($fd_desc)":"")
+	   ) unless ref($_[0]);
+    }
     _load_hires;
 
     my $start = start_timer();
@@ -209,8 +241,10 @@
             barf "exec failed; $!";
         }
     }
-    mutter sprintf("command completed in ".show_elapsed($start))
-	if $VERBOSE > 0;
+
+    if ( $VERBOSE >= $SHOW_CMD_VERBOSE ) {
+	say sprintf("command completed in ".show_elapsed($start))
+    }
 
     return $?
 
@@ -430,17 +464,61 @@
 sub show_elapsed {
      my $e = tv_interval($_[0]||$start, [gettimeofday()]);
 
-     return sci_unit($e, "s", 3);
+     return time_unit($e, 3);
 }
 
 sub show_delta {
     my $now;
     my $e = tv_interval($_[0]||$last, $now = [gettimeofday()]);
     $last = $now;
-    return sci_unit($e, "s", 3);
+    return time_unit($e, 3);
 }
 
 use POSIX qw(ceil);
+my @time_mul = (["w", 7*86400], ["d", 86400, " "], ["h", 3600, ":"],
+		["m", 60, ":" ], ["s", 1, 0],
+		[ "ms", 0.001 ], [ "us", 1e-6 ], ["ns", 1e-9]);
+sub time_unit {
+    my $scalar = shift;
+    my $d = (shift) || 4;
+    if ($scalar == 0) {
+        return "0s";
+    }
+    my $quanta = exp(log($scalar)-2.3025851*$d);
+    my $rem = $scalar+0;
+    my $rv = "";
+    for my $i (0..$#time_mul) {
+    	my $unit = $time_mul[$i];
+	if ($rv or $unit->[1] <= $rem ) {
+	   my $x = int($rem/$unit->[1]);
+	   my $new_rem = ($x ? $rem - ($x*$unit->[1]) : $rem);
+	   my $last = ($time_mul[$i+1][1]<$quanta);
+    	   if ($last and $new_rem >= $unit->[1]/2) {
+	       $x++;
+	   }
+	   if (!$last and $unit->[2]) {
+	       $rv .= $x.$unit->[0].$unit->[2];
+	   }
+	   elsif (defined $unit->[2] and !$unit->[2]) {
+	       # stop at seconds
+	       my $prec = ceil(-log($quanta)/log(10)-1.01);
+	       if ( $prec >= 1 ) {
+		       $rv .= sprintf("%.${prec}f", $rem).$unit->[0];
+	       }
+	       else {
+		       $rv .= sprintf("%d", $rem).$unit->[0];
+	       }
+	       last;
+	   }
+	   else {
+	       $rv .= $x.$unit->[0];
+	   }
+	   last if $last;
+	   $rem = $new_rem;
+	}
+    }
+    $rv;
+}
 
 my %prefixes=(18=>"E",15=>"P",12=>"T",9=>"G",6=>"M",3=>"k",0=>"",
 	      -3=>"m",-6=>"u",-9=>"n",-12=>"p",-15=>"f",-18=>"a");
@@ -468,7 +546,12 @@
 
 sub getconf {
     my $conf_obj;
-    eval 'use YAML'; barf "failed to include YAML; $@" if $@;
+    eval 'use YAML';
+    if ($@) {
+    	local($gotconf) = 1;
+        moan "failed to include YAML; not able to load config";
+	return @_;
+    }
     for my $loc ( "$ENV{HOME}/.${PROGNAME}rc",
 		  "/etc/perl/$PROGNAME.conf",
 		  "/etc/$PROGNAME.conf",
@@ -497,8 +580,12 @@
 
 sub getconf_f {
     my $filename = shift;
-    eval 'use YAML'; barf "failed to include YAML; $@" if $@;
-
+    eval 'use YAML';
+    if ($@) {
+    	local($gotconf) = 1;
+        moan "failed to include YAML; not able to load config";
+	return @_;
+    }
     my $conf_obj;
 
     if ( $filename eq "POD" ) {
@@ -727,7 +814,7 @@
     my $prompt = shift;
     my $default = shift;
     prompt_sub($prompt.(defined($default)?" [$default]":""),
-		 sub { $_ || $default });
+		 sub { $_ || $default || $_ });
 }
 
 sub prompt_int {
@@ -741,23 +828,26 @@
 sub prompt_nY { prompt_Yn(@_) }
 sub prompt_Yn {
     prompt_sub ($_[0]." [Yn]",
-		  sub {( /^\s*(?: (?:(y.*))? | (n.*))\s*$/ix &&
-			 ($2 ? 0 : (defined($1) ? 1 : undef)) 
-		       )} );
-}
+		sub { ( /^\s*(?: (?:(y.*))? | (n.*))\s*$/ix
+			? ($2 ? 0 : 1)
+			: undef )},
+	       );
+}
+sub prompt_ny { prompt_yn(@_) }
 sub prompt_yn {
     prompt_sub ($_[0]." [yn]",
-		  sub {( /^\s*(?: (y.*) | (n.*))\s*$/ix &&
-			 ($2 ? 0 : ($1 ? 1 : undef)) 
-		       )},
-		  "please enter `yes', or `no'" );
+		sub {( /^\s*(?: (y.*) | (n.*))\s*$/ix
+		       ? ($2 ? 0 : ($1 ? 1 : undef))
+		       : undef
+		     )},
+		"please enter `yes', or `no'" );
 }
 sub prompt_Ny { prompt_yN(@_) }
 sub prompt_yN {
     prompt_sub ($_[0]." [Ny]",
-		  sub {( /^\s*(?: (y.*)? | (?:(n.*))? )\s*$/ix &&
-			 ($1 ? 1 : (defined($2) ? 0 : undef)) 
-		       )} );
+		sub {( /^\s*(?: (y.*)? | (?:(n.*))? )\s*$/ix
+		       ? ($1 ? 1 : 0)
+		       : undef )} );
 }
 
 sub prompt_file {
@@ -1003,6 +1093,7 @@
     my @data;
     if ( open(my $script, $0) ) {
 	"" =~ m{()};  # clear $1
+	local(*_);
 	while ( <$script> ) {
 	    if ( m{^__\Q$name\E__$} .. (m{^__(?!\Q$name\E)(\w+)__$}||eof $script) ) {
 		$found++ or next;

Modified: branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod (original)
+++ branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod Fri Jun 27 08:44:41 2008
@@ -137,6 +137,11 @@
 configuration of B<Getopt::Long>.  To alter the configuration, simply
 call C<Getopt::Long::config>.  See L<Getopt::Long> for more
 information.
+
+=item B<getopt_lenient(@getopt_args)>
+
+Just like C<getopt()>, but doesn't cause a fatal error if there are
+any unknown options.
 
 =item B<getconf(@getopt_args)>
 
@@ -328,6 +333,16 @@
 
    my ($rc, @output) = capture_err("somecommand", @args);
 
+=item B<hush_exec()>
+
+=item B<unhush_exec()>
+
+C<hush_exec> is used to indicate that the programs you are running are
+only of interest to someone debugging the script.  So, the messages
+showing commands run and giving execution timings will not be printed
+without C<-vv> (double verbose) or C<-d> (debug, which is the same
+thing).
+
 =item B<start_timer()>
 
 =item B<show_delta()>
@@ -348,6 +363,25 @@
 From Scriptalicious 1.08, the "u" character is used in place of the
 Greek "mu" due to encoding compatibility issues.
 
+=item B<time_unit($num, [$precision])>
+
+Converts a floating point number of seconds to a human-readable time,
+the precision specifies the number of significant decimal digits,
+which is used to compute a "quanta" for the value given, values below
+which are not displayed.  $precision defaults to 4.
+
+examples:
+
+ time_unit(10.1) => "10.10s"
+ time_unit(1) => "1.000s"
+ time_unit(0.1) => "100ms"
+ time_unit(86401,2) => "1d 0h"
+ time_unit(86401,3) => "1d 0h"
+ time_unit(86401) => "1d 0h:0m"
+ time_unit(86400+3600/2) => "1d 0h:30m"
+ time_unit(86401,5) => "1d 0h:0m:1s"
+ time_unit(7*86400) => "1w0d 0h"
+
 =item B<prompt_regex($prompt, qr/(.*)/)>
 
 Prompts for something, using the prompt "C<$prompt>", matching the
@@ -390,6 +424,8 @@
 =item B<prompt_yN([$prompt])>
 
 prompts for yes or no, presuming yes and no, respectively.
+
+You can also spell these as C<prompt_nY> and C<prompt_Ny>.
 
 =item B<anydump($ref)>
 
@@ -454,13 +490,23 @@
 contrasting to this module's approach of elegant simplicity (quiet in
 the cheap seats!).
 
+L<Getopt::EUCLID> is Damian Conway's take on this.
+
 If you have solved this problem in a new and interesting way, or even
 rehashed it in an old, boring and inelegant way and want your module
 to be listed here, please contact the
 
-=head1 AUTHOR
-
-Sam Vilain, samv at cpan.org
+=head1 AUTHOR AND LICENSE
+
+Sam Vilain, L<samv at cpan.org>
+
+Copyright 2005-2008, Sam Vilain.  All rights reserved.  This program
+is free software; you can use it and/or distribute it under the same
+terms as Perl itself; either the latest stable release of Perl when
+the module was written, or any subsequent stable release.
+
+Please note that this applies retrospectively to all Scriptalicious
+releases; apologies for the lack of an explicit license.
 
 =cut
 

Modified: branches/upstream/libscriptalicious-perl/current/t/01-mmmdelicious.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/01-mmmdelicious.t?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/01-mmmdelicious.t (original)
+++ branches/upstream/libscriptalicious-perl/current/t/01-mmmdelicious.t Fri Jun 27 08:44:41 2008
@@ -33,5 +33,5 @@
 is($error, 0, "capture_err() - error code");
 is($output, `head -5 $0`, "capture_err() - output");
 
-like(show_delta, qr/^\d+(\.\d+)?[mµ]?s$/, "show_delta");
-like(show_elapsed, qr/^\d+(\.\d+)?[mµ]?s$/, "show_elapsed");
+like(show_delta, qr/^\d+(\.\d+)?[mu]?s$/, "show_delta");
+like(show_elapsed, qr/^\d+(\.\d+)?[mu]?s$/, "show_elapsed");

Modified: branches/upstream/libscriptalicious-perl/current/t/02-script.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/02-script.t?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/02-script.t (original)
+++ branches/upstream/libscriptalicious-perl/current/t/02-script.t Fri Jun 27 08:44:41 2008
@@ -1,4 +1,6 @@
 #!/usr/bin/perl -w
+
+for (qw|readonly|) {
 
 use strict;
 
@@ -25,3 +27,5 @@
     = capture_err($^X, "-Mlib=$path", "t/pu.pl", "--version");
 $output = join "", @output;
 like($output, qr/^This is pu, version 1.00/m, "spots invalid arguments");
+
+}

Modified: branches/upstream/libscriptalicious-perl/current/t/03-yaml.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/03-yaml.t?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/03-yaml.t (original)
+++ branches/upstream/libscriptalicious-perl/current/t/03-yaml.t Fri Jun 27 08:44:41 2008
@@ -1,6 +1,16 @@
 # -*- perl -*-
 
-use Test::More tests => 9;
+use Test::More;
+
+BEGIN {
+    eval { require YAML; YAML->import };
+    if ($@) {
+        plan skip_all => "YAML not installed";
+    }
+    else {
+        plan tests => 9;
+    }
+}
 
 BEGIN {
     use_ok( 'Scriptalicious', -progname => "myscript" );

Modified: branches/upstream/libscriptalicious-perl/current/t/04-fork.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/04-fork.t?rev=22207&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/04-fork.t (original)
+++ branches/upstream/libscriptalicious-perl/current/t/04-fork.t Fri Jun 27 08:44:41 2008
@@ -1,4 +1,9 @@
 #!/usr/bin/perl
+
+# Copyright 2005-2008, Sam Vilain.  All rights reserved.  This program
+# is free software; you can use it and/or distribute it under the same
+# terms as Perl itself; either the latest stable release of Perl when
+# the module was written, or any subsequent stable release.
 
 use warnings;
 use strict;
@@ -42,7 +47,7 @@
 $output = slurp $testfile;
 like($output, qr/:.*Loop this!/, "run -out => 'FILENAME'");
 
-$output = capture( -out => sub { my $foo = readline STDIN;
+$output = capture( -out => sub { my $foo = <STDIN>;
 				 slop $testfile, $foo;
 			     },
 		   -in  => sub { print "slopslopslop\n" },
@@ -76,7 +81,7 @@
 
 # last out!
 $output = capture( -in5 => sub { print "slurpamunchalot\n" },
-		   -out4  => sub { my $foo = readline STDIN;
+		   -out4  => sub { my $foo = <STDIN>;
 				   slop $testfile, $foo },
 		   $^X, "-Mlib=lib", "t/loopback.pl", qw(-o 4 -i 5));
 is($output, "", "run -out4 => CODE, -in4 => CODE (no output from capture)");

Added: branches/upstream/libscriptalicious-perl/current/t/06-anydump.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/06-anydump.t?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/06-anydump.t (added)
+++ branches/upstream/libscriptalicious-perl/current/t/06-anydump.t Fri Jun 27 08:44:41 2008
@@ -1,0 +1,27 @@
+#  -*- perl -*-
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Scriptalicious;
+
+$ENV{PERL5LIB} = join ":", "lib", split ":", ($ENV{PERL5LIB} || "");
+
+SKIP: {
+    eval 'use YAML';
+    if ( $@ ) {
+	skip "YAML not installed",1;
+    }
+    my $output = capture($^X, "t/dump.pl");
+    is($output, "Hello: world", "YAML anydump");
+}
+
+$ENV{PERL5LIB} = join ":", "t/missing", split ":", ($ENV{PERL5LIB} || "");
+delete $ENV{PERL5OPT};
+
+my $output = capture($^X, "t/dump.pl");
+is($output, q{$x = {
+       'Hello' => 'world'
+     };}, "Data::Dumper anydump");

Added: branches/upstream/libscriptalicious-perl/current/t/07-tsay.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/07-tsay.t?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/07-tsay.t (added)
+++ branches/upstream/libscriptalicious-perl/current/t/07-tsay.t Fri Jun 27 08:44:41 2008
@@ -1,0 +1,41 @@
+#  -*- perl -*-
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Scriptalicious;
+
+$ENV{PERL5LIB} = join ":", "lib", split ":", ($ENV{PERL5LIB} || "");
+
+SKIP: {
+    eval 'use Template';
+    if ( $@ ) {
+	skip "Template not installed", 1;
+    }
+
+    my $output = capture($^X, "t/tsay.pl");
+    is($output, "Hello, Bernie
+tsay.pl: Yo momma's so fat your family portrait has stretchmarks.", "Template say");
+}
+
+$ENV{PERL5LIB} = join ":", "t/missing", split ":", ($ENV{PERL5LIB} || "");
+delete $ENV{PERL5OPT};
+
+my $output = capture($^X, "t/tsay.pl");
+my $expected = <<'EOM';
+tsay.pl: warning: failed to include YAML; not able to load config
+tsay.pl: warning: install Template Toolkit for prettier messages
+tsay.pl: ----- Template `hello' -----
+Hello, [% name %]
+[% INCLUDE yomomma -%]
+tsay.pl: ------ Template variables ------
+$x = {
+       'name' => 'Bernie'
+     };
+tsay.pl: -------- end of message --------
+EOM
+chomp($expected);
+
+is($output, $expected, "no Template say");

Added: branches/upstream/libscriptalicious-perl/current/t/08-unit.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/08-unit.t?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/08-unit.t (added)
+++ branches/upstream/libscriptalicious-perl/current/t/08-unit.t Fri Jun 27 08:44:41 2008
@@ -1,0 +1,17 @@
+#!/usr/bin/perl -w
+#
+
+use Test::More no_plan;
+BEGIN { use_ok( "Scriptalicious" ) };
+
+open POD, "<blib/lib/Scriptalicious.pod" or die $!;
+my @data = grep { /^ time_unit/..!/^ time_unit/ } <POD>;
+close POD;
+
+ok(@data, "sanity - found examples in the man page");
+
+for (@data) {
+   next unless /\S/;
+   my ($input, $return) = m{\(([^)]+)\)\s*=>\s*"([^"]+)"} or die;
+   is(time_unit(eval $input), $return, "time_unit($input)");
+}

Added: branches/upstream/libscriptalicious-perl/current/t/09-noyaml.t
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/09-noyaml.t?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/09-noyaml.t (added)
+++ branches/upstream/libscriptalicious-perl/current/t/09-noyaml.t Fri Jun 27 08:44:41 2008
@@ -1,0 +1,19 @@
+# -*- perl -*-
+
+use lib "t/missing";
+use Test::More tests => 2;
+
+use_ok( 'Scriptalicious', -progname => "noyaml" );
+
+{
+local(*STDERR);
+open STDERR, ">/dev/null";
+getconf_f
+    ("t/eg.conf",
+     ( "something|s" => \$foo,
+     )
+    );
+}
+
+is($foo, undef, 
+   "didn't load config without YAML (and didn't die)");

Added: branches/upstream/libscriptalicious-perl/current/t/dump.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/dump.pl?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/dump.pl (added)
+++ branches/upstream/libscriptalicious-perl/current/t/dump.pl Fri Jun 27 08:44:41 2008
@@ -1,0 +1,4 @@
+
+use Scriptalicious;
+
+print anydump({ Hello => "world" });

Added: branches/upstream/libscriptalicious-perl/current/t/missing/Pod/Constants.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/missing/Pod/Constants.pm?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/missing/Pod/Constants.pm (added)
+++ branches/upstream/libscriptalicious-perl/current/t/missing/Pod/Constants.pm Fri Jun 27 08:44:41 2008
@@ -1,0 +1,1 @@
+failed!

Added: branches/upstream/libscriptalicious-perl/current/t/missing/Template.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/missing/Template.pm?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/missing/Template.pm (added)
+++ branches/upstream/libscriptalicious-perl/current/t/missing/Template.pm Fri Jun 27 08:44:41 2008
@@ -1,0 +1,2 @@
+
+die "dummy not installed emulation";

Added: branches/upstream/libscriptalicious-perl/current/t/missing/YAML.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/missing/YAML.pm?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/missing/YAML.pm (added)
+++ branches/upstream/libscriptalicious-perl/current/t/missing/YAML.pm Fri Jun 27 08:44:41 2008
@@ -1,0 +1,2 @@
+
+die "dummy not installed emulation";

Added: branches/upstream/libscriptalicious-perl/current/t/tsay.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libscriptalicious-perl/current/t/tsay.pl?rev=22207&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/t/tsay.pl (added)
+++ branches/upstream/libscriptalicious-perl/current/t/tsay.pl Fri Jun 27 08:44:41 2008
@@ -1,0 +1,12 @@
+
+use Scriptalicious;
+
+tsay hello => { name => "Bernie" };
+
+__END__
+
+__hello__
+Hello, [% name %]
+[% INCLUDE yomomma -%]
+__yomomma__
+[% PROGNAME %]: Yo momma's so fat your family portrait has stretchmarks.




More information about the Pkg-perl-cvs-commits mailing list