r59015 - in /branches/upstream/libpath-class-perl/current: Changes MANIFEST META.yml SIGNATURE lib/Path/Class.pm lib/Path/Class/Dir.pm lib/Path/Class/Entity.pm lib/Path/Class/File.pm t/01-basic.t t/03-filesystem.t t/04-subclass.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Mon Jun 7 11:14:25 UTC 2010


Author: ansgar-guest
Date: Mon Jun  7 10:59:01 2010
New Revision: 59015

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

Added:
    branches/upstream/libpath-class-perl/current/t/04-subclass.t
Modified:
    branches/upstream/libpath-class-perl/current/Changes
    branches/upstream/libpath-class-perl/current/MANIFEST
    branches/upstream/libpath-class-perl/current/META.yml
    branches/upstream/libpath-class-perl/current/SIGNATURE
    branches/upstream/libpath-class-perl/current/lib/Path/Class.pm
    branches/upstream/libpath-class-perl/current/lib/Path/Class/Dir.pm
    branches/upstream/libpath-class-perl/current/lib/Path/Class/Entity.pm
    branches/upstream/libpath-class-perl/current/lib/Path/Class/File.pm
    branches/upstream/libpath-class-perl/current/t/01-basic.t
    branches/upstream/libpath-class-perl/current/t/03-filesystem.t

Modified: branches/upstream/libpath-class-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/Changes?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/Changes (original)
+++ branches/upstream/libpath-class-perl/current/Changes Mon Jun  7 10:59:01 2010
@@ -1,4 +1,23 @@
 Revision history for Perl extension Path::Class.
+
+0.19 - Sun Jun  6 20:50:27 CDT 2010
+
+ - slurp() now accepts an 'iolayers' option to control how the file is
+   opened. [Graham Barr]
+
+ - In the openr() and openw() file methods, we now croak() instead of
+   die() so that the error messages are more useful. [Ian Sillitoe]
+
+ - Allow subclassing, by adding dir_class() and file_class() static
+   methods, allowing them to be overridden. [Matt Trout & John LoVerso
+   & Michael Schwern]
+
+ - Fixed a testing failure that could occur whenever testing in a
+   directory path that contains symlinks (e.g. /tmp on Mac OS X).
+
+ - Added a 'no_hidden' parameter for children() [EDENC <EDENC at cpan.org>]
+
+ - Fixed the heading for the is_relative() POD section. [CUB <cub.uanic at gmail.com>]
 
 0.18 - Sun Dec 20 10:11:02 CST 2009
 

Modified: branches/upstream/libpath-class-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/MANIFEST?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/MANIFEST (original)
+++ branches/upstream/libpath-class-perl/current/MANIFEST Mon Jun  7 10:59:01 2010
@@ -12,4 +12,5 @@
 t/01-basic.t
 t/02-foreign.t
 t/03-filesystem.t
+t/04-subclass.t
 SIGNATURE    Added here by Module::Build

Modified: branches/upstream/libpath-class-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/META.yml?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/META.yml (original)
+++ branches/upstream/libpath-class-perl/current/META.yml Mon Jun  7 10:59:01 2010
@@ -1,6 +1,6 @@
 ---
 name: Path-Class
-version: 0.18
+version: 0.19
 author:
   - 'Ken Williams, KWILLIAMS at cpan.org'
 abstract: Cross-platform path specification manipulation
@@ -27,16 +27,16 @@
 provides:
   Path::Class:
     file: lib/Path/Class.pm
-    version: 0.18
+    version: 0.19
   Path::Class::Dir:
     file: lib/Path/Class/Dir.pm
-    version: 0.18
+    version: 0.19
   Path::Class::Entity:
     file: lib/Path/Class/Entity.pm
-    version: 0.18
+    version: 0.19
   Path::Class::File:
     file: lib/Path/Class/File.pm
-    version: 0.18
+    version: 0.19
 generated_by: Module::Build version 0.34
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html

Modified: branches/upstream/libpath-class-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/SIGNATURE?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/SIGNATURE (original)
+++ branches/upstream/libpath-class-perl/current/SIGNATURE Mon Jun  7 10:59:01 2010
@@ -15,23 +15,24 @@
 Hash: SHA1
 
 SHA1 3e94b50826015fe7ac1e769cadd656b53317d4ab Build.PL
-SHA1 53e53939719140b2c7a8b40ce80271ab7136bec7 Changes
+SHA1 63cb36758d11d863e8e571b0f17350e513e73aaf Changes
 SHA1 066a2dba8084a0c2a7e4b6996ad21872bc16beb5 INSTALL
-SHA1 f38532f135ebd170454a00805504b38e89e0ae45 MANIFEST
-SHA1 f9a102dbc92707f088c02927886a7802fac4c3ff META.yml
+SHA1 a0a13d88e63cfd5b6f8a6ce1d23838c407b747e0 MANIFEST
+SHA1 00ee2bcb5f7534eeea92414289f947d1635b99f8 META.yml
 SHA1 13ec5ef969c9758358bdd8b5cd6b71e7e9d775d9 Makefile.PL
 SHA1 a7b1cdcddb8679dff993b475939abcfb73076afb README
-SHA1 280e55c273c8477e3cba803d55d7e3da32addd79 lib/Path/Class.pm
-SHA1 96bded96bf637945f61c51a1343fdbc6bb1204f0 lib/Path/Class/Dir.pm
-SHA1 9f57fa6892675473a08d38e68dbc69265857afc0 lib/Path/Class/Entity.pm
-SHA1 071f26594c4b1bae1deb36cc88d1f9fa4f56839d lib/Path/Class/File.pm
-SHA1 220f7d1d24731b7ae889e1b74c4306dbe552ffca t/01-basic.t
+SHA1 c080857efd0adb9512f786b55b3ccec24c44ba07 lib/Path/Class.pm
+SHA1 52ac59589dbb2012e956a2c1b2a3b8e57f1bb009 lib/Path/Class/Dir.pm
+SHA1 58f74f651664e537ad77f671222c15141e7aee13 lib/Path/Class/Entity.pm
+SHA1 2fffcf838bfd4ce9685c05096abe957c6cfb2ad4 lib/Path/Class/File.pm
+SHA1 97e2033418d3819f5ebf199d79bf7e87371bf164 t/01-basic.t
 SHA1 a42f4b07e4c42e7a59b960b13c5466d7cd82e17a t/02-foreign.t
-SHA1 6d11d3c96fd1db41c336d3014e3224076e283676 t/03-filesystem.t
+SHA1 24d2084a948436d73ce01e4f12db41c575d097bb t/03-filesystem.t
+SHA1 a163d4cf70142b45974ed39c78571e7ce2ba5a7f t/04-subclass.t
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (Darwin)
 
-iD8DBQFLLkzGgrvMBLfvlHYRAhOUAKCPxlij4/xWHp8on6oHYOvmGctTcgCfYIuX
-u9L8eaNynr/UMYbYGwXd0FA=
-=gxNA
+iD8DBQFMDFEegrvMBLfvlHYRAoqvAJ0VE8+5f75S4syeBSRQP92GugI2QACgg/vX
+BIVv1OSNZnTOOA5GJiK2uR8=
+=CjOC
 -----END PGP SIGNATURE-----

Modified: branches/upstream/libpath-class-perl/current/lib/Path/Class.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/lib/Path/Class.pm?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/lib/Path/Class.pm (original)
+++ branches/upstream/libpath-class-perl/current/lib/Path/Class.pm Mon Jun  7 10:59:01 2010
@@ -1,6 +1,6 @@
 package Path::Class;
 
-$VERSION = '0.18';
+$VERSION = '0.19';
 @ISA = qw(Exporter);
 @EXPORT    = qw(file dir);
 @EXPORT_OK = qw(file dir foreign_file foreign_dir);

Modified: branches/upstream/libpath-class-perl/current/lib/Path/Class/Dir.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/lib/Path/Class/Dir.pm?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/lib/Path/Class/Dir.pm (original)
+++ branches/upstream/libpath-class-perl/current/lib/Path/Class/Dir.pm Mon Jun  7 10:59:01 2010
@@ -1,15 +1,19 @@
 package Path::Class::Dir;
 
-$VERSION = '0.18';
+$VERSION = '0.19';
 
 use strict;
 use Path::Class::File;
-use Path::Class::Entity;
 use Carp();
 use base qw(Path::Class::Entity);
 
 use IO::Dir ();
 use File::Path ();
+
+# updir & curdir on the local machine, for screening them out in
+# children().  Note that they don't respect 'foreign' semantics.
+my $Updir  = __PACKAGE__->_spec->updir;
+my $Curdir = __PACKAGE__->_spec->curdir;
 
 sub new {
   my $self = shift->SUPER::new();
@@ -33,6 +37,8 @@
   return $self;
 }
 
+sub file_class { "Path::Class::File" }
+
 sub is_dir { 1 }
 
 sub as_foreign {
@@ -62,7 +68,7 @@
 
 sub file {
   local $Path::Class::Foreign = $_[0]->{file_spec_class} if $_[0]->{file_spec_class};
-  return Path::Class::File->new(@_);
+  return $_[0]->file_class->new(@_);
 }
 
 sub dir_list {
@@ -174,12 +180,19 @@
   
   my @out;
   while (defined(my $entry = $dh->read)) {
-    # XXX What's the right cross-platform way to do this?
-    next if (!$opts{all} && ($entry eq '.' || $entry eq '..'));
+    next if !$opts{all} && $self->_is_local_dot_dir($entry);
+    next if ($opts{no_hidden} && $entry =~ /^\./);
     push @out, $self->file($entry);
     $out[-1] = $self->subdir($entry) if -d $out[-1];
   }
   return @out;
+}
+
+sub _is_local_dot_dir {
+  my $self = shift;
+  my $dir  = shift;
+
+  return ($dir eq $Updir or $dir eq $Curdir);
 }
 
 sub next {
@@ -461,6 +474,13 @@
   @c = $dir->children(); # Just the children
   @c = $dir->children(all => 1); # All entries
 
+In addition, there's a C<no_hidden> parameter that will exclude all
+normally "hidden" entries - on Unix this means excluding all entries
+that begin with a dot (C<.>):
+
+  @c = $dir->children(no_hidden => 1); # Just normally-visible entries
+
+
 =item $abs = $dir->absolute
 
 Returns a C<Path::Class::Dir> object representing C<$dir> as an
@@ -614,6 +634,12 @@
 Same as C<stat()>, but if C<$file> is a symbolic link, C<lstat()>
 stats the link instead of the directory the link points to.
 
+=item $class = $file->file_class()
+
+Returns the class which should be used to create file objects.
+
+Generally overriden whenever this class is subclassed.
+
 =back
 
 =head1 AUTHOR

Modified: branches/upstream/libpath-class-perl/current/lib/Path/Class/Entity.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/lib/Path/Class/Entity.pm?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/lib/Path/Class/Entity.pm (original)
+++ branches/upstream/libpath-class-perl/current/lib/Path/Class/Entity.pm Mon Jun  7 10:59:01 2010
@@ -1,6 +1,6 @@
 package Path::Class::Entity;
 
-$VERSION = '0.18';
+$VERSION = '0.19';
 
 use strict;
 use File::Spec;
@@ -39,7 +39,7 @@
   return $class->new(@_);
 }
 
-sub _spec { $_[0]->{file_spec_class} || 'File::Spec' }
+sub _spec { (ref($_[0]) && $_[0]->{file_spec_class}) || 'File::Spec' }
 
 sub boolify { 1 }
   

Modified: branches/upstream/libpath-class-perl/current/lib/Path/Class/File.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/lib/Path/Class/File.pm?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/lib/Path/Class/File.pm (original)
+++ branches/upstream/libpath-class-perl/current/lib/Path/Class/File.pm Mon Jun  7 10:59:01 2010
@@ -1,11 +1,11 @@
 package Path::Class::File;
 
-$VERSION = '0.18';
+$VERSION = '0.19';
 
 use strict;
 use Path::Class::Dir;
-use Path::Class::Entity;
 use base qw(Path::Class::Entity);
+use Carp;
 
 use IO::File ();
 
@@ -20,11 +20,13 @@
     push @dirs, $self->_spec->catpath($volume, $dirs, '');
   }
   
-  $self->{dir}  = @dirs ? Path::Class::Dir->new(@dirs) : undef;
+  $self->{dir}  = @dirs ? $self->dir_class->new(@dirs) : undef;
   $self->{file} = $base;
   
   return $self;
 }
+
+sub dir_class { "Path::Class::Dir" }
 
 sub as_foreign {
   my ($self, $type) = @_;
@@ -44,7 +46,7 @@
 sub dir {
   my $self = shift;
   return $self->{dir} if defined $self->{dir};
-  return Path::Class::Dir->new($self->_spec->curdir);
+  return $self->dir_class->new($self->_spec->curdir);
 }
 BEGIN { *parent = \&dir; }
 
@@ -57,8 +59,8 @@
 sub basename { shift->{file} }
 sub open  { IO::File->new(@_) }
 
-sub openr { $_[0]->open('r') or die "Can't read $_[0]: $!"  }
-sub openw { $_[0]->open('w') or die "Can't write $_[0]: $!" }
+sub openr { $_[0]->open('r') or croak "Can't read $_[0]: $!"  }
+sub openw { $_[0]->open('w') or croak "Can't write $_[0]: $!" }
 
 sub touch {
   my $self = shift;
@@ -72,7 +74,8 @@
 
 sub slurp {
   my ($self, %args) = @_;
-  my $fh = $self->openr;
+  my $iomode = $args{iomode} || 'r';
+  my $fh = $self->open($iomode) or croak "Can't read $self: $!";
 
   if ($args{chomped} or $args{chomp}) {
     chomp( my @data = <$fh> );
@@ -194,7 +197,7 @@
 Returns true or false depending on whether the file refers to an
 absolute path specifier (like C</usr/local/foo.txt> or C<\Windows\Foo.txt>).
 
-=item $file->is_absolute
+=item $file->is_relative
 
 Returns true or false depending on whether the file refers to a
 relative path specifier (like C<lib/foo.txt> or C<.\Foo.txt>).
@@ -270,13 +273,13 @@
 
 A shortcut for
 
- $fh = $file->open('r') or die "Can't read $file: $!";
+ $fh = $file->open('r') or croak "Can't read $file: $!";
 
 =item $fh = $file->openw()
 
 A shortcut for
 
- $fh = $file->open('w') or die "Can't write $file: $!";
+ $fh = $file->open('w') or croak "Can't write $file: $!";
 
 =item $file->touch
 
@@ -296,6 +299,16 @@
 
   my @lines = $file->slurp(chomp => 1);
 
+You may also use the C<iomode> paramter to pass in an IO mode to use
+when opening the file, usually IO layers (though anything accepted by
+the MODE argument of C<open()> is accepted here).  Just make sure it's
+a I<reading> mode.
+
+  my @lines = $file->slurp(iomode => ':crlf');
+  my $lines = $file->slurp(iomode => '<:encoding(UTF−8)');
+
+The default C<iomode> is C<r>.
+
 =item $file->remove()
 
 This method will remove the file in a way that works well on all
@@ -317,6 +330,12 @@
 Same as C<stat()>, but if C<$file> is a symbolic link, C<lstat()>
 stats the link instead of the file the link points to.
 
+=item $class = $file->dir_class()
+
+Returns the class which should be used to create directory objects.
+
+Generally overriden whenever this class is subclassed.
+
 =back
 
 =head1 AUTHOR

Modified: branches/upstream/libpath-class-perl/current/t/01-basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/t/01-basic.t?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/t/01-basic.t (original)
+++ branches/upstream/libpath-class-perl/current/t/01-basic.t Mon Jun  7 10:59:01 2010
@@ -79,7 +79,7 @@
   ok dir(''), '/';
   ok dir(), '.';
   ok dir('', 'var', 'tmp'), '/var/tmp';
-  ok dir()->absolute, dir(Cwd::cwd())->cleanup;
+  ok dir()->absolute->resolve, dir(Cwd::cwd())->resolve;
   ok dir(undef), undef;
 }
 

Modified: branches/upstream/libpath-class-perl/current/t/03-filesystem.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/t/03-filesystem.t?rev=59015&op=diff
==============================================================================
--- branches/upstream/libpath-class-perl/current/t/03-filesystem.t (original)
+++ branches/upstream/libpath-class-perl/current/t/03-filesystem.t Mon Jun  7 10:59:01 2010
@@ -4,7 +4,7 @@
 use File::Temp qw(tmpnam tempdir);
 use File::Spec;
 
-plan tests => 72;
+plan tests => 78;
 
 use_ok 'Path::Class';
 
@@ -142,6 +142,31 @@
 
   @content = $file->slurp(chomp => 1);
   is_deeply \@content, ["Line1", "Line2"];
+
+  $file->remove;
+  ok not -e $file;
+}
+
+{
+  my $file = file('t', 'slurp');
+  ok $file;
+  
+  my $fh = $file->open('>:raw') or die "Can't create $file: $!";
+  print $fh "Line1\r\nLine2\r\n\302\261\r\n";
+  close $fh;
+  ok -e $file;
+  
+  my $content = $file->slurp(iomode => '<:raw');
+  is $content, "Line1\r\nLine2\r\n\302\261\r\n";
+  
+  my $line3 = "\302\261\n";
+  utf8::decode($line3);
+  my @content = $file->slurp(iomode => '<:crlf:utf8');
+  is_deeply \@content, ["Line1\n", "Line2\n", $line3];
+
+  chop($line3);
+  @content = $file->slurp(chomp => 1, iomode => '<:crlf:utf8');
+  is_deeply \@content, ["Line1", "Line2", $line3];
 
   $file->remove;
   ok not -e $file;

Added: branches/upstream/libpath-class-perl/current/t/04-subclass.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpath-class-perl/current/t/04-subclass.t?rev=59015&op=file
==============================================================================
--- branches/upstream/libpath-class-perl/current/t/04-subclass.t (added)
+++ branches/upstream/libpath-class-perl/current/t/04-subclass.t Mon Jun  7 10:59:01 2010
@@ -1,0 +1,36 @@
+#!/usr/bin/perl
+
+# Test subclassing of Path::Class
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+
+{
+    package My::File;
+    use base qw(Path::Class::File);
+
+    sub dir_class { return "My::Dir" }
+}
+
+{
+    package My::Dir;
+    use base qw(Path::Class::Dir);
+
+    sub file_class { return "My::File" }
+}
+
+{
+    my $file = My::File->new("/path/to/some/file");
+    isa_ok $file, "My::File";
+    is $file->as_foreign("Unix"), "/path/to/some/file";
+
+    my $dir = $file->dir;
+    isa_ok $dir, "My::Dir";
+    is $dir->as_foreign("Unix"), "/path/to/some";
+
+    my $file_again = $dir->file("bar");
+    isa_ok $file_again, "My::File";
+    is $file_again->as_foreign("Unix"), "/path/to/some/bar";
+}




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