r57388 - in /branches/upstream/libscriptalicious-perl/current: Changes.pod MANIFEST MANIFEST.SKIP META.yml Makefile.PL SIGNATURE lib/Scriptalicious.pm lib/Scriptalicious.pod

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon May 3 14:22:30 UTC 2010


Author: jawnsy-guest
Date: Mon May  3 14:22:12 2010
New Revision: 57388

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

Added:
    branches/upstream/libscriptalicious-perl/current/SIGNATURE
Removed:
    branches/upstream/libscriptalicious-perl/current/MANIFEST.SKIP
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

Modified: branches/upstream/libscriptalicious-perl/current/Changes.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscriptalicious-perl/current/Changes.pod?rev=57388&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/Changes.pod (original)
+++ branches/upstream/libscriptalicious-perl/current/Changes.pod Mon May  3 14:22:12 2010
@@ -1,5 +1,41 @@
 
 =head1 WHATS NEW IN SCRIPTALICIOUS
+
+=head2 VERSION 1.16
+
+=over
+
+=item Clear PERL5OPT before invoking $^X in tests
+
+To hopefully resolve some false failures
+
+=item Fix code for case when Time::HiRes is not available
+
+I never got a report about this, but it clearly didn't work!  Guess
+no-one's using a Perl before 5.7.3 or without that module any more.
+
+=item put the magic AUTOLOAD back
+
+Scriptalicious will do most of its core stuff without compiling most
+of itself, and there is an AUTOLOAD hook which puts them into place.
+I decided to re-enable it.
+
+=item remove (soft) dependency on Pod::Constants
+
+Scriptalicious scripts are less delicious without a working --help,
+and many systems did not bother with this soft dependency, so it is
+of benefit to just implement what that code did instead.
+
+=item new $CONFIG variable
+
+Used for telling where config was read from (or specifying where it is
+to be read from)
+
+=item deal with negative values in sci_unit and time_unit
+
+These functions didn't deal with negative input; fix that.
+
+=back
 
 =head2 VERSION 1.15
 
@@ -9,10 +45,6 @@
 
 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
 

Modified: branches/upstream/libscriptalicious-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscriptalicious-perl/current/MANIFEST?rev=57388&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/MANIFEST (original)
+++ branches/upstream/libscriptalicious-perl/current/MANIFEST Mon May  3 14:22:12 2010
@@ -3,8 +3,8 @@
 lib/Scriptalicious.pod
 Makefile.PL
 MANIFEST			This list of files
-MANIFEST.SKIP
 README
+SIGNATURE
 t/01-mmmdelicious.t
 t/02-script.t
 t/03-yaml.t

Modified: branches/upstream/libscriptalicious-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscriptalicious-perl/current/META.yml?rev=57388&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/META.yml (original)
+++ branches/upstream/libscriptalicious-perl/current/META.yml Mon May  3 14:22:12 2010
@@ -1,15 +1,21 @@
 --- #YAML:1.0
-name:                Scriptalicious
-version:             1.15
-abstract:            Make scripts more delicious to SysAdmins
-license:             ~
-author:              
+name:               Scriptalicious
+version:            1.16
+abstract:           Make scripts more delicious to SysAdmins
+author:
     - Sam Vilain <samv at cpan.org>
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    Term::ReadKey:                 0
-    Test::More:                    0
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Term::ReadKey:  0
+    Test::More:     0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.48
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: branches/upstream/libscriptalicious-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscriptalicious-perl/current/Makefile.PL?rev=57388&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/Makefile.PL (original)
+++ branches/upstream/libscriptalicious-perl/current/Makefile.PL Mon May  3 14:22:12 2010
@@ -3,7 +3,7 @@
 use ExtUtils::MakeMaker;
 # See perldoc Module::Build for details of how this works
 
-my @recommends = qw(Text::Wrap Time::HiRes YAML Pod::Constants);
+my @recommends = qw(Text::Wrap Time::HiRes YAML);
 
 for my $module ( @recommends ) {
     eval "use $module";

Added: branches/upstream/libscriptalicious-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscriptalicious-perl/current/SIGNATURE?rev=57388&op=file
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/SIGNATURE (added)
+++ branches/upstream/libscriptalicious-perl/current/SIGNATURE Mon May  3 14:22:12 2010
@@ -1,0 +1,49 @@
+This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.55.
+
+To verify the content in this distribution, first make sure you have
+Module::Signature installed, then type:
+
+    % cpansign -v
+
+It will check each file's integrity, as well as the signature's
+validity.  If "==> Signature verified OK! <==" is not displayed,
+the distribution may already have been compromised, and you should
+not run its Makefile.PL or Build.PL.
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+SHA1 cdbedaa9a1fe96c2d6de54a4a9cd5b647df27902 Changes.pod
+SHA1 e18250e2c44106baeb5f4d0104a3f4c58ffc0a1f MANIFEST
+SHA1 0fa9575de5e9a121ca074b68aae2d669909f3a74 Makefile.PL
+SHA1 260379dc3c27fc8aa6e64273b0b94580fda0750d README
+SHA1 c8af5bfce471d1b31a42fe2e31010944c6d93d3d lib/Scriptalicious.pm
+SHA1 ebe921c9ed03ba874b4cb073a6a3d8714d479a5b lib/Scriptalicious.pod
+SHA1 4fa577b375f1bd148f072ecf56079c5d19b6cdd0 t/01-mmmdelicious.t
+SHA1 14b11bbbc6e41cf3e018a00f99f8ae63e369c028 t/02-script.t
+SHA1 13216c981df5928b2e72034bc6cfb17964b0483f t/03-yaml.t
+SHA1 91ba3e39ceda09362a5dedff0e213818537ed03d t/04-fork.t
+SHA1 fca1712dcc759e3eb3e1033dcb5bd71f3ec8f590 t/05-prompt.t
+SHA1 25a798e881538c59b3ec548c209ba5b02f1b7130 t/06-anydump.t
+SHA1 b9d619e9eb205cc321442e9b22462f4dc92fa915 t/07-tsay.t
+SHA1 be2c3bd65c45847938219492142254b6645274a3 t/08-unit.t
+SHA1 68aff9f78699052e3a3b3b1653d6fa8fbdb0d794 t/09-noyaml.t
+SHA1 8078519cfb2b235edb7c89c33b31d29af1a6dc7f t/Util.pm
+SHA1 faaf4c3ba63c7978ba348aebbceedfc1d8b8d639 t/dump.pl
+SHA1 0923940238fc4b05b2af2b029e32ac8c67ea6e6e t/eg.conf
+SHA1 6c70d4016856ac3941c077ed9df8d2d1e98d547a t/fork.pl
+SHA1 945fe09f02d32b8d75d0ae110d48d833b443d0b9 t/loopback.pl
+SHA1 fe7c9271665cda30ced18f74c5442d4864f04075 t/missing/Pod/Constants.pm
+SHA1 dacb6cd4c86d4dda967ab60037dddc36dd0e8c68 t/missing/Template.pm
+SHA1 dacb6cd4c86d4dda967ab60037dddc36dd0e8c68 t/missing/YAML.pm
+SHA1 f70a86242836ca20d5546db52c164a9ec045f508 t/prompter.pl
+SHA1 fc3174c15673596fb885b8843da1ad22ce531d96 t/pu.pl
+SHA1 a91f4452b7d540b79df8ab2be7766c7739c62804 t/tsay.pl
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+iEYEARECAAYFAkveQDcACgkQ/AZAiGayWEN3xQCeN57hGFEncHDuwwLbaGe+SV7D
+pWwAnieNQvYdCkOAZFgyNpTw3denyvlo
+=4miL
+-----END PGP SIGNATURE-----

Modified: branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm?rev=57388&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm (original)
+++ branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pm Mon May  3 14:22:12 2010
@@ -14,7 +14,7 @@
 use warnings;
 use Carp qw(croak);
 
-our $VERSION = "1.15";
+our $VERSION = "1.16";
 
 use Getopt::Long;
 use base qw(Exporter);
@@ -24,6 +24,7 @@
 
     our @EXPORT = qw(say mutter whisper abort moan barf run run_err
 		     capture capture_err getopt $VERBOSE $PROGNAME
+		     $CONFIG
 		     start_timer show_delta show_elapsed getconf
 		     getconf_f sci_unit prompt_for prompt_passwd
 		     prompt_yn prompt_Yn prompt_yN prompt_string
@@ -66,6 +67,7 @@
 
 # automatically guess the program name if called for
 (our $PROGNAME = $0) =~ s{.*/}{} unless $PROGNAME;
+our $CONFIG;
 
 BEGIN {
     Getopt::Long::config("bundling", "pass_through");
@@ -196,7 +198,7 @@
     eval "use Time::HiRes qw(gettimeofday tv_interval)";
     *gettimeofday = sub { return time() }
 	unless defined &gettimeofday;
-    *tv_interval = sub { return ${$_[0]} - ${$_[1]} }
+    *tv_interval = sub { return ${$_[0]}[0] - ${$_[1]}[0] }
 	unless defined &tv_interval;
 }
 
@@ -266,80 +268,90 @@
     die "capture2 not implemented yet"
 }
 
-#our $DATA = join "", <DATA>;  close DATA;
-#our ($AUTOLOAD, $l);sub AUTOLOAD{croak"No such function $AUTOLOAD"if
-#$l;(undef,my($f,$n))=ll();$n+=1;eval"package ".__PACKAGE__.";\n"
-#."# line $n \"$f\"\n$DATA"; $@&&die"Error in autoload: $@";
-#$l=1;goto &{$AUTOLOAD};}sub ll{sub{caller()}->();}     "P E A C E";
-#__DATA__
+our $DATA = join "", <DATA>;  close DATA;
+our ($AUTOLOAD, $l);sub AUTOLOAD{croak"No such function $AUTOLOAD"if
+$l;(undef,my($f,$n))=ll();$n+=1;eval"package ".__PACKAGE__.";\n"
+."# line $n \"$f\"\n$DATA"; $@&&die"Error in autoload: $@";
+$l=1;goto &{$AUTOLOAD};}sub ll{sub{caller()}->();}     "P E A C E";
+__DATA__
 
 our ($NAME, $SHORT_DESC, $SYNOPSIS, $DESCRIPTION, @options);
 
 #---------------------------------------------------------------------
-#  calls Pod::Constants to get the synopsis, etc, from the calling
-#  script.
+#  get the synopsis, etc, from the calling script.
 #---------------------------------------------------------------------
 sub _get_pod_usage {
-    return if $SYNOPSIS;
-    (undef, my ($fn, $line)) = sub{caller()}->();
-    eval "# line $line \"$fn\"\npackage main;\n".q{
-        our $level;
-        use Pod::Constants;
-        Pod::Constants::import_from_file($0, -trim => 1,
-            'NAME' => sub {
-	my @m;
-	( @m = m/(\S+) - (.*)/ ) &&
-	    do { $Scriptalicious::PROGNAME = $m[0];
-		 $Scriptalicious::SHORT_DESC = $m[1]; }
-	},
-            'SYNOPSIS' => \$Scriptalicious::SYNOPSIS,
-            'DESCRIPTION' => \$Scriptalicious::DESCRIPTION,
-            'COMMAND LINE OPTIONS' => sub {
-	        &Pod::Constants::add_hook
-		   ('*item' => sub {
-                     return unless $level == 1;
-		     my ($switches, $description) =
-			 m/^(.*?)\n\n(.*)/s;
-                     $switches =~ s{[BCI]<([^>]*)>}{$1}g;
-		     my (@switches, $longest);
-		     $longest = "";
-		     for my $switch
-			 ($switches =~ m/\G
-					 ((?:-\w|--\w+))
-					 (?:,\s*)?
-					 /gx) {
-			     push @switches, $switch;
-			     if ( length $switch > length $longest) {
-				 $longest = $switch;
-			     }
-			 }
-		     $longest =~ s/^-*//;
-		     push @options,
-			 $longest, {
-				    options => \@switches,
-				    description => $description,
-				   };
-                     });
-                &Pod::Constants::add_hook
-                   ("*over" => sub { $level++ });
-                &Pod::Constants::add_hook
-                   ("*back" => sub {
-                       --$level or do {
-                           &Pod::Constants::delete_hook($_)
-                               foreach qw(*over *back *item);
-                       };
-                    });
-            }
-        );
-    };
-
-    if ( $@ ) {
-	$SYNOPSIS = "(error: Pod::Constants failed to load)";
-    } else {
+	return if $SYNOPSIS;
+	our $level;
+	open SCR_POD, $0 or warn "failed to open $0 for reading; $!";
+	my $targ;
+	my $in_options;
+	my $name_desc;
+	local($_);
+	while (<SCR_POD>) {
+		if ( !m{^=} and $targ ) {
+			$$targ .= $_;
+		}
+		if ( m{^=encoding (\w+)} ) {
+			binmode SCR_POD, ":$1";
+		}
+		elsif ( m{^=head\w\s+SYNOPSIS\s*$} ) {
+			$targ = \$Scriptalicious::SYNOPSIS;
+		}
+		elsif ( m{^=head\w\s+DESCRIPTION\s*$} ) {
+			$targ = \$Scriptalicious::DESCRIPTION;
+		}
+		elsif ( m{^=head\w\s+NAME\s*$} ) {
+			$targ = \$name_desc;
+		}
+		elsif ( m{^=head\w\s+COMMAND[\- ]LINE OPTIONS\s*$} ) {
+			undef($targ);
+			$in_options = 1;
+		}
+		elsif ( $in_options ) {
+			if ( m{^=over} ) {
+				$level++
+			}
+			elsif ( m{^=item\s+(.*)} ) {
+				next unless $level == 1;
+				my $switches = $1;
+				$switches =~ s{[BCI]<([^>]*)>}{$1}g;
+				my (@switches, $longest);
+				$longest = "";
+				for my $switch
+					($switches =~ m/\G
+							((?:-\w|--\w+))
+							(?:,\s*)?
+						       /gx) {
+					push @switches, $switch;
+					if ( length $switch > length $longest) {
+						$longest = $switch;
+					}
+				}
+				$longest =~ s/^-*//;
+				my $opt_hash = {
+					options => \@switches,
+					description => "",
+				};
+				$targ = \$opt_hash->{description};
+				push @options, $longest, $opt_hash;
+			}
+			elsif ( m{^=back} ) {
+				if ( --$level == 0 ) {
+					undef($in_options);
+				}
+			}
+		}
+	}
+	if ( $name_desc ) {
+		$name_desc =~ m{^(\S+)(?:\s+-\s+(.*))?$};
+		$PROGNAME ||= $1;
+		$SHORT_DESC ||= $2;
+	}
+
 	foreach ( $SYNOPSIS, $SHORT_DESC, $DESCRIPTION ) {
-	    $_ ||= "(no text found, no POD given?)";
-	}
-    }
+	    $_ ||= "(not found in POD)";
+	}
 }
 
 sub short_usage {
@@ -480,6 +492,10 @@
 		[ "ms", 0.001 ], [ "us", 1e-6 ], ["ns", 1e-9]);
 sub time_unit {
     my $scalar = shift;
+    my $neg = $scalar < 0;
+    if ($neg) { 
+        $scalar = -$scalar;
+    }
     my $d = (shift) || 4;
     if ($scalar == 0) {
         return "0s";
@@ -517,7 +533,7 @@
 	   $rem = $new_rem;
 	}
     }
-    $rv;
+    ($neg?"-":"").$rv;
 }
 
 my %prefixes=(18=>"E",15=>"P",12=>"T",9=>"G",6=>"M",3=>"k",0=>"",
@@ -525,6 +541,10 @@
 
 sub sci_unit {
     my $scalar = shift;
+    my $neg = $scalar < 0 ? "-" : "";
+    if ($neg) {
+        $scalar = -$scalar;
+    }
     my $unit = (shift) || "";
     my $d = (shift) || 4;
     my $e = 0;
@@ -536,10 +556,10 @@
     if (exists $prefixes{$e}) {
 	$d -= ceil(log($scalar)/log(10));
 	$d = 0 if $d < 0;
-	my $a = sprintf("%.${d}f", $scalar);
+	my $a = sprintf("%s%.${d}f", $neg, $scalar);
 	return $a.$prefixes{$e}.$unit;
     } else {
-	return sprintf("%${d}e", $scalar).$unit;
+	return sprintf("%s%${d}e", $neg, $scalar).$unit;
     }
 
 }
@@ -552,12 +572,13 @@
         moan "failed to include YAML; not able to load config";
 	return @_;
     }
-    for my $loc ( "$ENV{HOME}/.${PROGNAME}rc",
+    for my $loc ( $CONFIG,
+		  "$ENV{HOME}/.${PROGNAME}rc",
 		  "/etc/perl/$PROGNAME.conf",
 		  "/etc/$PROGNAME.conf",
 		  "POD"
 		) {
-	
+	next if not defined $loc;
 	eval {
 	    $conf_obj = getconf_f($loc, @_);
 	};
@@ -568,6 +589,7 @@
 		barf "error processing config file $loc; $@";
 	    }
 	} else {
+	    $CONFIG = $loc;
 	    last;
 	}
     }

Modified: branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod?rev=57388&op=diff
==============================================================================
--- branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod (original)
+++ branches/upstream/libscriptalicious-perl/current/lib/Scriptalicious.pod Mon May  3 14:22:12 2010
@@ -129,6 +129,12 @@
 It is recommended that you only ever read this variable, and pass it
 in via the import.  This is not automatically extracted from the POD
 for performance reasons.
+
+=item C<$CONFIG>
+
+Name of the configuration file.  Set before a call to C<getconf>, or
+read afterwards to see if a config file was used.  New in
+Scriptalicious 1.16
 
 =item B<getopt(@getopt_args)>
 
@@ -492,6 +498,10 @@
 
 L<Getopt::EUCLID> is Damian Conway's take on this.
 
+Finally, if you don't mind the dependencies of Moose (or Mouse), then
+L<MooseX::Getopt> and L<MooseX::SimpleConfig> are much more elegant
+approaches to getopt handling and configuration than this module.
+
 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




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