[Bps-public-commit] r18607 - in String-BufferStack: . inc/Module/Install lib/String

alexmv at bestpractical.com alexmv at bestpractical.com
Fri Feb 27 19:25:32 EST 2009


Author: alexmv
Date: Fri Feb 27 19:25:32 2009
New Revision: 18607

Added:
   String-BufferStack/README
Modified:
   String-BufferStack/   (props changed)
   String-BufferStack/Changes
   String-BufferStack/MANIFEST
   String-BufferStack/META.yml
   String-BufferStack/SIGNATURE
   String-BufferStack/inc/Module/Install.pm
   String-BufferStack/inc/Module/Install/Base.pm
   String-BufferStack/inc/Module/Install/Can.pm
   String-BufferStack/inc/Module/Install/Fetch.pm
   String-BufferStack/inc/Module/Install/Makefile.pm
   String-BufferStack/inc/Module/Install/Metadata.pm
   String-BufferStack/inc/Module/Install/Win32.pm
   String-BufferStack/inc/Module/Install/WriteAll.pm
   String-BufferStack/lib/String/BufferStack.pm

Log:
 r42819 at kohr-ah:  chmrr | 2009-02-27 19:20:01 -0500
 Add LICENSE and AUTHOR to POD; 1.13 releng
 r42820 at kohr-ah:  chmrr | 2009-02-27 19:25:06 -0500
 More 1.13 releng


Modified: String-BufferStack/Changes
==============================================================================
--- String-BufferStack/Changes	(original)
+++ String-BufferStack/Changes	Fri Feb 27 19:25:32 2009
@@ -1,5 +1,8 @@
 Revision history for String-BufferStack
 
+1.13   Fri Feb 27 19:19:17 2009
+        * No code changes; add LICENSE and AUTHOR to POD
+
 1.12   Wed Feb  4 14:41:17 2009
         * Add buffer_ref
         * Documentation adjustments

Modified: String-BufferStack/MANIFEST
==============================================================================
--- String-BufferStack/MANIFEST	(original)
+++ String-BufferStack/MANIFEST	Fri Feb 27 19:25:32 2009
@@ -12,6 +12,7 @@
 MANIFEST			This list of files
 MANIFEST.SKIP
 META.yml
+README
 SIGNATURE
 t/01-basic.t
 t/02-simple-stack.t

Modified: String-BufferStack/META.yml
==============================================================================
--- String-BufferStack/META.yml	(original)
+++ String-BufferStack/META.yml	Fri Feb 27 19:25:32 2009
@@ -1,18 +1,18 @@
---- 
-abstract: Nested buffers for templating systems
-author: 
-  - Alex Vandiver <alexmv at bestpractical.com>
+---
+abstract: 'Nested buffers for templating systems'
+author:
+  - 'Alex Vandiver <alexmv at bestpractical.com>'
 distribution_type: module
-generated_by: Module::Install version 0.70
+generated_by: 'Module::Install version 0.79'
 license: Artistic
-meta-spec: 
-  url: http://module-build.sourceforge.net/META-spec-v1.3.html
-  version: 1.3
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
 name: String-BufferStack
-no_index: 
-  directory: 
+no_index:
+  directory:
     - inc
     - t
-requires: 
+requires:
   perl: 5.8.0
-version: 1.12
+version: 1.13

Added: String-BufferStack/README
==============================================================================
--- (empty file)
+++ String-BufferStack/README	Fri Feb 27 19:25:32 2009
@@ -0,0 +1,176 @@
+NAME
+    String::BufferStack - Nested buffers for templating systems
+
+SYNOPSIS
+      my $stack = String::BufferStack->new;
+      $stack->push( filter => sub {return uc shift} );
+      $stack->append("content");
+      $stack->flush_output;
+
+DESCRIPTION
+    "String::BufferStack" provides a framework for storing nested buffers.
+    By default, all of the buffers flow directly to the output method, but
+    individual levels of the stack can apply filters, or store their output
+    in a scalar reference.
+
+METHODS
+  new PARAMHASH
+    Creates a new buffer stack and returns it. Possible arguments include:
+
+    prealoc
+        Preallocate this many bytes in the output buffer. This can reduce
+        reallocations, and thus speed up appends.
+
+    out_method
+        The method to call when output trickles down to the bottom-most
+        buffer and is flushed via flush_output. The default "out_method"
+        prints the content to "STDOUT". This method will always be called
+        with non-undef, non-zero length content.
+
+  push PARAMHASH
+    Pushes a new frame onto the buffer stack. By default, the output from
+    this new frame connects to the input of the previous frame. There are a
+    number of possible options:
+
+    buffer
+        A string reference, into which the output from this stack frame will
+        appear. By default, this is the input buffer of the previous frame.
+
+    private
+        If a true value is passed for "private", it creates a private string
+        reference, and uses that as the buffer -- this is purely for
+        convenience. That is, the following blocks are equivilent:
+
+          my $buffer = "";
+          $stack->push( buffer => \$buffer );
+          # ...
+          $stack->pop;
+          print $buffer;
+
+          $stack->push( private => 1 );
+          # ...
+          print $stack->pop;
+
+    pre_append
+        A callback, which will be called with a reference to the
+        "String::BufferStack" object, and the arguments to append, whenever
+        this stack frame has anything appended to the input buffer, directly
+        or indirectly.
+
+        Within the context of the pre-append callback, "append",
+        "direct_append", and "set_pre_append" function on the frame the
+        pre-append is attached to, not the topmost trame. Using "append"
+        within the pre-append callback is not suggested; use "direct_append"
+        instead. "set_pre_append" can be used to alter or remove the
+        pre-append callback itself -- this is not uncommon, in the case
+        where the first append is the only one which needs be watched for,
+        for instance.
+
+    filter
+        A callback, used to process data which is appended to the stack
+        frame. By default, filters are lazy, being called only when a frame
+        is popped. They can be forced at any time by calling
+        "flush_filters", however.
+
+  depth
+    Returns the current depth of the stack. This starts at 0, when no frames
+    have been pushed, and increases by one for each frame pushed.
+
+  append STRING [, STRING, ...]
+    Appends the given strings to the input side of the topmost buffer. This
+    will call all pre-append hooks attached to it, as well. Note that if the
+    frame has a filter, the filter will not immediately run, but will be
+    delayed until the frame is "pop"'d, or "flush_filters" is called.
+
+    When called with no frames on the stack, appends the stringins directly
+    to the "output_buffer".
+
+  direct_append STRING [, STRING, ...]
+    Similar to "append", but appends the strings to the output side of the
+    frame, skipping pre-append callbacks and filters.
+
+    When called with no frames on the stack, appends the strings directly to
+    the "output_buffer".
+
+  pop
+    Removes the topmost frame on the stack, flushing the topmost filters in
+    the process. Returns the output buffer of the frame -- note that this
+    may not contain only strings appended in the current frame, but also
+    those from before, as a speed optimization. That is:
+
+       $stack->append("one");
+       $stack->push;
+       $stack->append(" two");
+       $stack->pop;   # returns "one two"
+
+    This operation is a no-op if there are no frames on the stack.
+
+  set_pre_append CALLBACK
+    Alters the pre-append callback on the topmost frame. The callback will
+    be called before text is appended to the input buffer of the frame, and
+    will be passed the "String::BufferStack" and the arguments to "append".
+
+  set_filter FILTER
+    Alters the filter on the topmost frame. Doing this flushes the filters
+    on the topmost frame.
+
+  filter
+    Filters the topmost stack frame, if it has outstanding unfiltered data.
+    This will propagate content to lower frames, possibly calling their
+    pre-append hooks.
+
+  flush
+    If there are no frames on the stack, calls "flush_output". Otherwise,
+    calls "flush_filters".
+
+  flush_filters
+    Flushes all filters. This does not flush output from the output buffer;
+    see "flush_output".
+
+  buffer
+    Returns the contents of the output buffer of the topmost frame; if there
+    are no frames, returns the output buffer.
+
+  buffer_ref
+    Returns a reference to the output buffer of the topmost frame; if there
+    are no frames, returns a reference to the output buffer. Note that
+    adjusting this skips pre-append and filter hooks.
+
+  length
+    Returns the number of characters appended to the current frame; if there
+    are no frames, returns the length of the output buffer.
+
+  flush_output
+    Flushes all filters using "flush_filters", then flushes output from the
+    output buffer, using the configured "out_method".
+
+  output_buffer
+    Returns the pending output buffer, which sits below all existing frames.
+
+  output_buffer_ref
+    Returns a reference to the pending output buffer, allowing you to modify
+    it.
+
+  clear
+    Clears *all* buffers in the stack, including the output buffer.
+
+  clear_top
+    Clears the topmost buffer in the stack; if there are no frames on the
+    stack, clears the output buffer.
+
+  out_method [CALLBACK]
+    Gets or sets the output method callback, which is given content from the
+    pending output buffer, which sits below all frames.
+
+SEE ALSO
+    Many concepts were originally taken from HTML::Mason's internal buffer
+    stack.
+
+AUTHORS
+    Alex Vandiver "alexmv at bestpractical.com"
+
+LICENSE
+    Copyright 2008-2009, Best Practical Solutions.
+
+    This package is distributed under the same terms as Perl itself.
+

Modified: String-BufferStack/SIGNATURE
==============================================================================
--- String-BufferStack/SIGNATURE	(original)
+++ String-BufferStack/SIGNATURE	Fri Feb 27 19:25:32 2009
@@ -14,20 +14,21 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 77a221dfb83f9349f28ec92ff0718bf7f4fdb780 Changes
-SHA1 fb4dfbe1b8393a2a3114191cdba947a15da80ac3 MANIFEST
+SHA1 0509e7d55b4a5133937d3fd054bd8e7b3bdac306 Changes
+SHA1 199bc083c59728f3ad8a7b75014872e5032e7ab5 MANIFEST
 SHA1 7e740186be7996b6ce3ed345d17f9760678a5c6b MANIFEST.SKIP
-SHA1 8dc91abd11dde545fac64657b7d95736696e2adf META.yml
+SHA1 056bc43818bd24a8ab7435dc6125f48fcd6b86ef META.yml
 SHA1 7630604c507f12721ed80f4c9c2b150dde21eb6d Makefile.PL
-SHA1 8b836389e4bc170eb8d19b7296b2f4978ac36136 inc/Module/Install.pm
-SHA1 85b32a1d5f215d99f411c3dd6113b537fcd5c57d inc/Module/Install/Base.pm
-SHA1 fde745e180861c7c0ba3ee5a767cafdbdb1d3ebd inc/Module/Install/Can.pm
-SHA1 e259400ceb54c34def9c994f52d7091108ce7ffc inc/Module/Install/Fetch.pm
-SHA1 da42b522e5a7ffbae0ceec900f3635ad9990c565 inc/Module/Install/Makefile.pm
-SHA1 ba005818ee9f97146bfa4e14e53c684e9e446902 inc/Module/Install/Metadata.pm
-SHA1 85e6b1cf5b7ca81bfb469a99389fa947d4b8a08e inc/Module/Install/Win32.pm
-SHA1 d32dff9f0d2f02023ca6d79a48d62fd855916351 inc/Module/Install/WriteAll.pm
-SHA1 d0d33c2186eecde4b720cb859764d82fd74dcf50 lib/String/BufferStack.pm
+SHA1 dee3e130b392c8b6997be5ef899fd14a9370dabd README
+SHA1 ae018c4565c1277089ca8f1b28f888d95430cb7f inc/Module/Install.pm
+SHA1 4552acdfca8b78f8015d8449e1325616259095f5 inc/Module/Install/Base.pm
+SHA1 7fb663fff161fb45882b52edd62857bf15359658 inc/Module/Install/Can.pm
+SHA1 8b1d3db746faa6faf2d967a48d3812ec1f44b4c6 inc/Module/Install/Fetch.pm
+SHA1 9f6beaa2f4749ceb5dd0c9b0c647d0f3289c7b46 inc/Module/Install/Makefile.pm
+SHA1 7ad1da4fff7a1e7a634c9d734111c8292be08884 inc/Module/Install/Metadata.pm
+SHA1 e9aa83f3e8b16ccfce544a90a57b63b70a497759 inc/Module/Install/Win32.pm
+SHA1 ade2ac0b0246d4d8e28fa46942e53f6925abda46 inc/Module/Install/WriteAll.pm
+SHA1 9305e4ef0731b11c184189c31e2fbbd49a763b55 lib/String/BufferStack.pm
 SHA1 3a8cf31db6f3c50932215f43ee335190a5888084 t/01-basic.t
 SHA1 44ef8aa5cf63e875a4eea5b8043a1df9b8ff4fed t/02-simple-stack.t
 SHA1 2facb62ae74edb458c201635cf9156ffa63dcb16 t/03-capture.t
@@ -36,7 +37,7 @@
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.9 (GNU/Linux)
 
-iEYEARECAAYFAkmJ74AACgkQMflWJZZAbqBCFwCeKNAwvjHCWI2U705xZXHz07uZ
-yygAoIEaBLXDg2M31Gde8fZPBirbXuxF
-=kpNR
+iEYEARECAAYFAkmohEQACgkQMflWJZZAbqBNuwCfTy6rdl0iOugM86WZCjfjWkte
+W5MAnRSJTWwaR5SLfWWqDbE3teoKO0Cm
+=E9v0
 -----END PGP SIGNATURE-----

Modified: String-BufferStack/inc/Module/Install.pm
==============================================================================
--- String-BufferStack/inc/Module/Install.pm	(original)
+++ String-BufferStack/inc/Module/Install.pm	Fri Feb 27 19:25:32 2009
@@ -30,7 +30,11 @@
 	# This is not enforced yet, but will be some time in the next few
 	# releases once we can make sure it won't clash with custom
 	# Module::Install extensions.
-	$VERSION = '0.70';
+	$VERSION = '0.79';
+
+	*inc::Module::Install::VERSION = *VERSION;
+	@inc::Module::Install::ISA     = __PACKAGE__;
+
 }
 
 
@@ -81,7 +85,7 @@
 
 # Build.PL was formerly supported, but no longer is due to excessive
 # difficulty in implementing every single feature twice.
-if ( $0 =~ /Build.PL$/i or -f 'Build.PL' ) { die <<"END_DIE" }
+if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" }
 
 Module::Install no longer supports Build.PL.
 
@@ -95,14 +99,20 @@
 
 
 
+# To save some more typing in Module::Install installers, every...
+# use inc::Module::Install
+# ...also acts as an implicit use strict.
+$^H |= strict::bits(qw(refs subs vars));
+
+
+
+
+
 use Cwd        ();
 use File::Find ();
 use File::Path ();
 use FindBin;
 
-*inc::Module::Install::VERSION = *VERSION;
- at inc::Module::Install::ISA     = __PACKAGE__;
-
 sub autoload {
 	my $self = shift;
 	my $who  = $self->_caller;
@@ -115,8 +125,10 @@
 			goto &$code unless $cwd eq $pwd;
 		}
 		$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
-		unshift @_, ( $self, $1 );
-		goto &{$self->can('call')} unless uc($1) eq $1;
+		unless ( uc($1) eq $1 ) {
+			unshift @_, ( $self, $1 );
+			goto &{$self->can('call')};
+		}
 	};
 }
 
@@ -145,8 +157,7 @@
 }
 
 sub preload {
-	my ($self) = @_;
-
+	my $self = shift;
 	unless ( $self->{extensions} ) {
 		$self->load_extensions(
 			"$self->{prefix}/$self->{path}", $self
@@ -202,6 +213,7 @@
 		$args{path}  =~ s!::!/!g;
 	}
 	$args{file}     ||= "$args{base}/$args{prefix}/$args{path}.pm";
+	$args{wrote}      = 0;
 
 	bless( \%args, $class );
 }
@@ -238,7 +250,7 @@
 sub load_extensions {
 	my ($self, $path, $top) = @_;
 
-	unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) {
+	unless ( grep { !ref $_ and lc $_ eq lc $self->{prefix} } @INC ) {
 		unshift @INC, $self->{prefix};
 	}
 
@@ -277,9 +289,9 @@
 		# correctly.  Otherwise, root through the file to locate the case-preserved
 		# version of the package name.
 		if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
-			open PKGFILE, "<$subpath.pm" or die "find_extensions: Can't open $subpath.pm: $!";
-			my $in_pod = 0;
-			while ( <PKGFILE> ) {
+			my $content = Module::Install::_read($subpath . '.pm');
+			my $in_pod  = 0;
+			foreach ( split //, $content ) {
 				$in_pod = 1 if /^=\w/;
 				$in_pod = 0 if /^=cut/;
 				next if ($in_pod || /^=cut/);  # skip pod text
@@ -289,7 +301,6 @@
 					last;
 				}
 			}
-			close PKGFILE;
 		}
 
 		push @found, [ $file, $pkg ];
@@ -298,6 +309,13 @@
 	@found;
 }
 
+
+
+
+
+#####################################################################
+# Utility Functions
+
 sub _caller {
 	my $depth = 0;
 	my $call  = caller($depth);
@@ -308,6 +326,44 @@
 	return $call;
 }
 
+sub _read {
+	local *FH;
+	open FH, "< $_[0]" or die "open($_[0]): $!";
+	my $str = do { local $/; <FH> };
+	close FH or die "close($_[0]): $!";
+	return $str;
+}
+
+sub _write {
+	local *FH;
+	open FH, "> $_[0]" or die "open($_[0]): $!";
+	foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!" }
+	close FH or die "close($_[0]): $!";
+}
+
+# _version is for processing module versions (eg, 1.03_05) not
+# Perl versions (eg, 5.8.1).
+
+sub _version ($) {
+	my $s = shift || 0;
+	   $s =~ s/^(\d+)\.?//;
+	my $l = $1 || 0;
+	my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g;
+	   $l = $l . '.' . join '', @v if @v;
+	return $l + 0;
+}
+
+# Cloned from Params::Util::_CLASS
+sub _CLASS ($) {
+	(
+		defined $_[0]
+		and
+		! ref $_[0]
+		and
+		$_[0] =~ m/^[^\W\d]\w*(?:::\w+)*$/s
+	) ? $_[0] : undef;
+}
+
 1;
 
-# Copyright 2008 Adam Kennedy.
+# Copyright 2008 - 2009 Adam Kennedy.

Modified: String-BufferStack/inc/Module/Install/Base.pm
==============================================================================
--- String-BufferStack/inc/Module/Install/Base.pm	(original)
+++ String-BufferStack/inc/Module/Install/Base.pm	Fri Feb 27 19:25:32 2009
@@ -1,7 +1,7 @@
 #line 1
 package Module::Install::Base;
 
-$VERSION = '0.70';
+$VERSION = '0.79';
 
 # Suspend handler for "redefined" warnings
 BEGIN {
@@ -45,6 +45,8 @@
     $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new;
 }
 
+#line 101
+
 sub is_admin {
     $_[0]->admin->VERSION;
 }
@@ -67,4 +69,4 @@
 
 1;
 
-#line 138
+#line 146

Modified: String-BufferStack/inc/Module/Install/Can.pm
==============================================================================
--- String-BufferStack/inc/Module/Install/Can.pm	(original)
+++ String-BufferStack/inc/Module/Install/Can.pm	Fri Feb 27 19:25:32 2009
@@ -11,7 +11,7 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.70';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
@@ -39,6 +39,7 @@
 	return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
 
 	for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
+		next if $dir eq '';
 		my $abs = File::Spec->catfile($dir, $_[1]);
 		return $abs if (-x $abs or $abs = MM->maybe_command($abs));
 	}
@@ -79,4 +80,4 @@
 
 __END__
 
-#line 157
+#line 158

Modified: String-BufferStack/inc/Module/Install/Fetch.pm
==============================================================================
--- String-BufferStack/inc/Module/Install/Fetch.pm	(original)
+++ String-BufferStack/inc/Module/Install/Fetch.pm	Fri Feb 27 19:25:32 2009
@@ -6,20 +6,20 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.70';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 
 sub get_file {
     my ($self, %args) = @_;
-    my ($scheme, $host, $path, $file) = 
+    my ($scheme, $host, $path, $file) =
         $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
 
     if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) {
         $args{url} = $args{ftp_url}
             or (warn("LWP support unavailable!\n"), return);
-        ($scheme, $host, $path, $file) = 
+        ($scheme, $host, $path, $file) =
             $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
     }
 

Modified: String-BufferStack/inc/Module/Install/Makefile.pm
==============================================================================
--- String-BufferStack/inc/Module/Install/Makefile.pm	(original)
+++ String-BufferStack/inc/Module/Install/Makefile.pm	Fri Feb 27 19:25:32 2009
@@ -7,7 +7,7 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.70';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
@@ -36,9 +36,9 @@
 
 sub makemaker_args {
 	my $self = shift;
-	my $args = ($self->{makemaker_args} ||= {});
-	  %$args = ( %$args, @_ ) if @_;
-	$args;
+	my $args = ( $self->{makemaker_args} ||= {} );
+	%$args = ( %$args, @_ );
+	return $args;
 }
 
 # For mm args that take multiple space-seperated args,
@@ -63,18 +63,18 @@
 sub clean_files {
 	my $self  = shift;
 	my $clean = $self->makemaker_args->{clean} ||= {};
-	%$clean = (
-		%$clean, 
-		FILES => join(' ', grep length, $clean->{FILES}, @_),
+	  %$clean = (
+		%$clean,
+		FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_),
 	);
 }
 
 sub realclean_files {
-	my $self  = shift;
+	my $self      = shift;
 	my $realclean = $self->makemaker_args->{realclean} ||= {};
-	%$realclean = (
-		%$realclean, 
-		FILES => join(' ', grep length, $realclean->{FILES}, @_),
+	  %$realclean = (
+		%$realclean,
+		FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_),
 	);
 }
 
@@ -116,13 +116,19 @@
 
 	# Make sure we have a new enough
 	require ExtUtils::MakeMaker;
-	$self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION );
 
-	# Generate the 
+	# MakeMaker can complain about module versions that include
+	# an underscore, even though its own version may contain one!
+	# Hence the funny regexp to get rid of it.  See RT #35800
+	# for details.
+
+	$self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
+
+	# Generate the
 	my $args = $self->makemaker_args;
 	$args->{DISTNAME} = $self->name;
-	$args->{NAME}     = $self->module_name || $self->name || $self->determine_NAME($args);
-	$args->{VERSION}  = $self->version || $self->determine_VERSION($args);
+	$args->{NAME}     = $self->module_name || $self->name;
+	$args->{VERSION}  = $self->version;
 	$args->{NAME}     =~ s/-/::/g;
 	if ( $self->tests ) {
 		$args->{test} = { TESTS => $self->tests };
@@ -175,7 +181,9 @@
 
 	my $user_preop = delete $args{dist}->{PREOP};
 	if (my $preop = $self->admin->preop($user_preop)) {
-		$args{dist} = $preop;
+		foreach my $key ( keys %$preop ) {
+			$args{dist}->{$key} = $preop->{$key};
+		}
 	}
 
 	my $mm = ExtUtils::MakeMaker::WriteMakefile(%args);
@@ -188,7 +196,7 @@
 	my $top_class     = ref($self->_top) || '';
 	my $top_version   = $self->_top->VERSION || '';
 
-	my $preamble = $self->preamble 
+	my $preamble = $self->preamble
 		? "# Preamble by $top_class $top_version\n"
 			. $self->preamble
 		: '';
@@ -242,4 +250,4 @@
 
 __END__
 
-#line 371
+#line 379

Modified: String-BufferStack/inc/Module/Install/Metadata.pm
==============================================================================
--- String-BufferStack/inc/Module/Install/Metadata.pm	(original)
+++ String-BufferStack/inc/Module/Install/Metadata.pm	Fri Feb 27 19:25:32 2009
@@ -6,25 +6,43 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.70';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 
 my @scalar_keys = qw{
-	name module_name abstract author version license
-	distribution_type perl_version tests installdirs
+	name
+	module_name
+	abstract
+	author
+	version
+	distribution_type
+	tests
+	installdirs
 };
 
 my @tuple_keys = qw{
-	configure_requires build_requires requires recommends bundles
+	configure_requires
+	build_requires
+	requires
+	recommends
+	bundles
+	resources
 };
 
-sub Meta            { shift        }
-sub Meta_ScalarKeys { @scalar_keys }
-sub Meta_TupleKeys  { @tuple_keys  }
+my @resource_keys = qw{
+	homepage
+	bugtracker
+	repository
+};
+
+sub Meta              { shift          }
+sub Meta_ScalarKeys   { @scalar_keys   }
+sub Meta_TupleKeys    { @tuple_keys    }
+sub Meta_ResourceKeys { @resource_keys }
 
-foreach my $key (@scalar_keys) {
+foreach my $key ( @scalar_keys ) {
 	*$key = sub {
 		my $self = shift;
 		return $self->{values}{$key} if defined wantarray and !@_;
@@ -33,33 +51,65 @@
 	};
 }
 
-foreach my $key (@tuple_keys) {
+foreach my $key ( @resource_keys ) {
 	*$key = sub {
 		my $self = shift;
-		return $self->{values}{$key} unless @_;
+		unless ( @_ ) {
+			return () unless $self->{values}{resources};
+			return map  { $_->[1] }
+			       grep { $_->[0] eq $key }
+			       @{ $self->{values}{resources} };
+		}
+		return $self->{values}{resources}{$key} unless @_;
+		my $uri = shift or die(
+			"Did not provide a value to $key()"
+		);
+		$self->resources( $key => $uri );
+		return 1;
+	};
+}
 
-		my @rv;
-		while (@_) {
-			my $module = shift or last;
+foreach my $key ( grep {$_ ne "resources"} @tuple_keys) {
+	*$key = sub {
+		my $self = shift;
+		return $self->{values}{$key} unless @_;
+		my @added;
+		while ( @_ ) {
+			my $module  = shift or last;
 			my $version = shift || 0;
-			if ( $module eq 'perl' ) {
-				$version =~ s{^(\d+)\.(\d+)\.(\d+)}
-				             {$1 + $2/1_000 + $3/1_000_000}e;
-				$self->perl_version($version);
-				next;
-			}
-			my $rv = [ $module, $version ];
-			push @rv, $rv;
+			push @added, [ $module, $version ];
 		}
-		push @{ $self->{values}{$key} }, @rv;
-		@rv;
+		push @{ $self->{values}{$key} }, @added;
+		return map {@$_} @added;
 	};
 }
 
+# Resource handling
+my %lc_resource = map { $_ => 1 } qw{
+	homepage
+	license
+	bugtracker
+	repository
+};
+
+sub resources {
+	my $self = shift;
+	while ( @_ ) {
+		my $name  = shift or last;
+		my $value = shift or next;
+		if ( $name eq lc $name and ! $lc_resource{$name} ) {
+			die("Unsupported reserved lowercase resource '$name'");
+		}
+		$self->{values}{resources} ||= [];
+		push @{ $self->{values}{resources} }, [ $name, $value ];
+	}
+	$self->{values}{resources};
+}
+
 # Aliases for build_requires that will have alternative
 # meanings in some future version of META.yml.
-sub test_requires      { shift->build_requires(@_)  }
-sub install_requires   { shift->build_requires(@_)  }
+sub test_requires      { shift->build_requires(@_) }
+sub install_requires   { shift->build_requires(@_) }
 
 # Aliases for installdirs options
 sub install_as_core    { $_[0]->installdirs('perl')   }
@@ -69,45 +119,87 @@
 
 sub sign {
 	my $self = shift;
-	return $self->{'values'}{'sign'} if defined wantarray and ! @_;
-	$self->{'values'}{'sign'} = ( @_ ? $_[0] : 1 );
+	return $self->{values}{sign} if defined wantarray and ! @_;
+	$self->{values}{sign} = ( @_ ? $_[0] : 1 );
 	return $self;
 }
 
 sub dynamic_config {
 	my $self = shift;
 	unless ( @_ ) {
-		warn "You MUST provide an explicit true/false value to dynamic_config, skipping\n";
+		warn "You MUST provide an explicit true/false value to dynamic_config\n";
 		return $self;
 	}
-	$self->{'values'}{'dynamic_config'} = $_[0] ? 1 : 0;
-	return $self;
+	$self->{values}{dynamic_config} = $_[0] ? 1 : 0;
+	return 1;
+}
+
+sub perl_version {
+	my $self = shift;
+	return $self->{values}{perl_version} unless @_;
+	my $version = shift or die(
+		"Did not provide a value to perl_version()"
+	);
+
+	# Normalize the version
+	$version = $self->_perl_version($version);
+
+	# We don't support the reall old versions
+	unless ( $version >= 5.005 ) {
+		die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n";
+	}
+
+	$self->{values}{perl_version} = $version;
+}
+
+sub license {
+	my $self = shift;
+	return $self->{values}{license} unless @_;
+	my $license = shift or die(
+		'Did not provide a value to license()'
+	);
+	$self->{values}{license} = $license;
+
+	# Automatically fill in license URLs
+	if ( $license eq 'perl' ) {
+		$self->resources( license => 'http://dev.perl.org/licenses/' );
+	}
+
+	return 1;
 }
 
 sub all_from {
 	my ( $self, $file ) = @_;
 
 	unless ( defined($file) ) {
-		my $name = $self->name
-			or die "all_from called with no args without setting name() first";
+		my $name = $self->name or die(
+			"all_from called with no args without setting name() first"
+		);
 		$file = join('/', 'lib', split(/-/, $name)) . '.pm';
 		$file =~ s{.*/}{} unless -e $file;
-		die "all_from: cannot find $file from $name" unless -e $file;
+		unless ( -e $file ) {
+			die("all_from cannot find $file from $name");
+		}
+	}
+	unless ( -f $file ) {
+		die("The path '$file' does not exist, or is not a file");
 	}
 
+	# Some methods pull from POD instead of code.
+	# If there is a matching .pod, use that instead
+	my $pod = $file;
+	$pod =~ s/\.pm$/.pod/i;
+	$pod = $file unless -e $pod;
+
+	# Pull the different values
+	$self->name_from($file)         unless $self->name;
 	$self->version_from($file)      unless $self->version;
 	$self->perl_version_from($file) unless $self->perl_version;
+	$self->author_from($pod)        unless $self->author;
+	$self->license_from($pod)       unless $self->license;
+	$self->abstract_from($pod)      unless $self->abstract;
 
-	# The remaining probes read from POD sections; if the file
-	# has an accompanying .pod, use that instead
-	my $pod = $file;
-	if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
-		$file = $pod;
-	}
-
-	$self->author_from($file)   unless $self->author;
-	$self->license_from($file)  unless $self->license;
-	$self->abstract_from($file) unless $self->abstract;
+	return 1;
 }
 
 sub provides {
@@ -169,8 +261,8 @@
 	while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
 		$self->feature( $name, @$mods );
 	}
-	return $self->{values}->{features}
-		? @{ $self->{values}->{features} }
+	return $self->{values}{features}
+		? @{ $self->{values}{features} }
 		: ();
 }
 
@@ -183,10 +275,10 @@
 
 sub read {
 	my $self = shift;
-	$self->include_deps( 'YAML', 0 );
+	$self->include_deps( 'YAML::Tiny', 0 );
 
-	require YAML;
-	my $data = YAML::LoadFile('META.yml');
+	require YAML::Tiny;
+	my $data = YAML::Tiny::LoadFile('META.yml');
 
 	# Call methods explicitly in case user has already set some values.
 	while ( my ( $key, $value ) = each %$data ) {
@@ -226,35 +318,51 @@
 	 );
 }
 
-sub _slurp {
-	local *FH;
-	open FH, "< $_[1]" or die "Cannot open $_[1].pod: $!";
-	do { local $/; <FH> };
+# Add both distribution and module name
+sub name_from {
+	my ($self, $file) = @_;
+	if (
+		Module::Install::_read($file) =~ m/
+		^ \s*
+		package \s*
+		([\w:]+)
+		\s* ;
+		/ixms
+	) {
+		my ($name, $module_name) = ($1, $1);
+		$name =~ s{::}{-}g;
+		$self->name($name);
+		unless ( $self->module_name ) {
+			$self->module_name($module_name);
+		}
+	} else {
+		die("Cannot determine name from $file\n");
+	}
 }
 
 sub perl_version_from {
-	my ( $self, $file ) = @_;
+	my $self = shift;
 	if (
-		$self->_slurp($file) =~ m/
+		Module::Install::_read($_[0]) =~ m/
 		^
-		use \s*
+		(?:use|require) \s*
 		v?
 		([\d_\.]+)
 		\s* ;
 		/ixms
 	) {
-		my $v = $1;
-		$v =~ s{_}{}g;
-		$self->perl_version($1);
+		my $perl_version = $1;
+		$perl_version =~ s{_}{}g;
+		$self->perl_version($perl_version);
 	} else {
-		warn "Cannot determine perl version info from $file\n";
+		warn "Cannot determine perl version info from $_[0]\n";
 		return;
 	}
 }
 
 sub author_from {
-	my ( $self, $file ) = @_;
-	my $content = $self->_slurp($file);
+	my $self    = shift;
+	my $content = Module::Install::_read($_[0]);
 	if ($content =~ m/
 		=head \d \s+ (?:authors?)\b \s*
 		([^\n]*)
@@ -268,15 +376,14 @@
 		$author =~ s{E<gt>}{>}g;
 		$self->author($author);
 	} else {
-		warn "Cannot determine author info from $file\n";
+		warn "Cannot determine author info from $_[0]\n";
 	}
 }
 
 sub license_from {
-	my ( $self, $file ) = @_;
-
+	my $self = shift;
 	if (
-		$self->_slurp($file) =~ m/
+		Module::Install::_read($_[0]) =~ m/
 		(
 			=head \d \s+
 			(?:licen[cs]e|licensing|copyright|legal)\b
@@ -288,8 +395,12 @@
 		my $license_text = $1;
 		my @phrases      = (
 			'under the same (?:terms|license) as perl itself' => 'perl',        1,
+			'GNU general public license'                      => 'gpl',         1,
 			'GNU public license'                              => 'gpl',         1,
+			'GNU lesser general public license'               => 'lgpl',        1,
 			'GNU lesser public license'                       => 'lgpl',        1,
+			'GNU library general public license'              => 'lgpl',        1,
+			'GNU library public license'                      => 'lgpl',        1,
 			'BSD license'                                     => 'bsd',         1,
 			'Artistic license'                                => 'artistic',    1,
 			'GPL'                                             => 'gpl',         1,
@@ -302,17 +413,98 @@
 		while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
 			$pattern =~ s{\s+}{\\s+}g;
 			if ( $license_text =~ /\b$pattern\b/i ) {
-				if ( $osi and $license_text =~ /All rights reserved/i ) {
-					warn "LEGAL WARNING: 'All rights reserved' may invalidate Open Source licenses. Consider removing it.";
-				}
 				$self->license($license);
 				return 1;
 			}
 		}
 	}
 
-	warn "Cannot determine license info from $file\n";
+	warn "Cannot determine license info from $_[0]\n";
 	return 'unknown';
 }
 
+sub bugtracker_from {
+	my $self    = shift;
+	my $content = Module::Install::_read($_[0]);
+	my @links   = $content =~ m/L\<(http\:\/\/rt\.cpan\.org\/[^>]+)\>/g;
+	unless ( @links ) {
+		warn "Cannot determine bugtracker info from $_[0]\n";
+		return 0;
+	}
+	if ( @links > 1 ) {
+		warn "Found more than on rt.cpan.org link in $_[0]\n";
+		return 0;
+	}
+
+	# Set the bugtracker
+	bugtracker( $links[0] );
+	return 1;
+}
+
+# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to
+# numbers (eg, 5.006001 or 5.008009).
+# Also, convert double-part versions (eg, 5.8)
+sub _perl_version {
+	my $v = $_[-1];
+	$v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e;	
+	$v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e;
+	$v =~ s/(\.\d\d\d)000$/$1/;
+	$v =~ s/_.+$//;
+	if ( ref($v) ) {
+		$v = $v + 0; # Numify
+	}
+	return $v;
+}
+
+
+
+
+
+######################################################################
+# MYMETA.yml Support
+
+sub WriteMyMeta {
+	$_[0]->write_mymeta;
+}
+
+sub write_mymeta {
+	my $self = shift;
+	
+	# If there's no existing META.yml there is nothing we can do
+	return unless -f 'META.yml';
+
+	# Merge the perl version into the dependencies
+	my $val  = $self->Meta->{values};
+	my $perl = delete $val->{perl_version};
+	if ( $perl ) {
+		$val->{requires} ||= [];
+		my $requires = $val->{requires};
+
+		# Canonize to three-dot version after Perl 5.6
+		if ( $perl >= 5.006 ) {
+			$perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e
+		}
+		unshift @$requires, [ perl => $perl ];
+	}
+
+	# Load the advisory META.yml file
+	require YAML::Tiny;
+	my @yaml = YAML::Tiny::LoadFile('META.yml');
+	my $meta = $yaml[0];
+
+	# Overwrite the non-configure dependency hashs
+	delete $meta->{requires};
+	delete $meta->{build_requires};
+	delete $meta->{recommends};
+	if ( exists $val->{requires} ) {
+		$meta->{requires} = { map { @$_ } @{ $val->{requires} } };
+	}
+	if ( exists $val->{build_requires} ) {
+		$meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } };
+	}
+
+	# Save as the MYMETA.yml file
+	YAML::Tiny::DumpFile('MYMETA.yml', $meta);
+}
+
 1;

Modified: String-BufferStack/inc/Module/Install/Win32.pm
==============================================================================
--- String-BufferStack/inc/Module/Install/Win32.pm	(original)
+++ String-BufferStack/inc/Module/Install/Win32.pm	Fri Feb 27 19:25:32 2009
@@ -6,7 +6,7 @@
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.70';
+	$VERSION = '0.79';
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }

Modified: String-BufferStack/inc/Module/Install/WriteAll.pm
==============================================================================
--- String-BufferStack/inc/Module/Install/WriteAll.pm	(original)
+++ String-BufferStack/inc/Module/Install/WriteAll.pm	Fri Feb 27 19:25:32 2009
@@ -6,7 +6,7 @@
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.70';
+	$VERSION = '0.79';
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }

Modified: String-BufferStack/lib/String/BufferStack.pm
==============================================================================
--- String-BufferStack/lib/String/BufferStack.pm	(original)
+++ String-BufferStack/lib/String/BufferStack.pm	Fri Feb 27 19:25:32 2009
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-our $VERSION; $VERSION = "1.12";
+our $VERSION; $VERSION = "1.13";
 
 =head1 NAME
 
@@ -452,4 +452,22 @@
     return $self->{out_method};
 }
 
+=head1 SEE ALSO
+
+Many concepts were originally taken from L<HTML::Mason>'s internal
+buffer stack.
+
+=head1 AUTHORS
+
+Alex Vandiver C<< alexmv at bestpractical.com >>
+
+=head1 LICENSE
+
+Copyright 2008-2009, Best Practical Solutions.
+
+This package is distributed under the same terms as Perl itself.
+
+=cut
+
+
 1;



More information about the Bps-public-commit mailing list