[Moose-commits] r7294 - in File-Stat-Moose/trunk: . lib/Exception lib/File/Stat lib/MooseX/Types t t/tlib/File/Stat xt

dexter at code2.0beta.co.uk dexter at code2.0beta.co.uk
Mon Jan 12 15:11:00 GMT 2009


Author: dexter
Date: 2009-01-12 07:10:59 -0800 (Mon, 12 Jan 2009)
New Revision: 7294

Modified:
   File-Stat-Moose/trunk/
   File-Stat-Moose/trunk/Build.PL
   File-Stat-Moose/trunk/Changes
   File-Stat-Moose/trunk/Incompatibilities
   File-Stat-Moose/trunk/lib/Exception/IO.pm
   File-Stat-Moose/trunk/lib/File/Stat/Moose.pm
   File-Stat-Moose/trunk/lib/MooseX/Types/CacheFileHandle.pm
   File-Stat-Moose/trunk/lib/MooseX/Types/OpenHandle.pm
   File-Stat-Moose/trunk/t/all_tests.t
   File-Stat-Moose/trunk/t/test.pl
   File-Stat-Moose/trunk/t/tlib/File/Stat/MooseTest.pm
   File-Stat-Moose/trunk/xt/consistent_version_numbers.t
   File-Stat-Moose/trunk/xt/copyright.t
   File-Stat-Moose/trunk/xt/perlcriticrc
Log:
* New method "update".
* Methods "stat" and "lstat" are deprecared.
* Attribute "file" is required.
* All attributes are "ro".
* New attribute "spec" contains the class name of File::Spec class.



Property changes on: File-Stat-Moose/trunk
___________________________________________________________________
Name: svn:ignore
   - .settings
.includepath
.project

   + .settings
.includepath
.project

Build

Debian_CPANTS.txt

Makefile.PL

META.yml

*.tmp

README

cover_db

_build

blib


Modified: File-Stat-Moose/trunk/Build.PL
===================================================================
--- File-Stat-Moose/trunk/Build.PL	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/Build.PL	2009-01-12 15:10:59 UTC (rev 7294)
@@ -1,13 +1,17 @@
 #!/usr/bin/perl
 
-use Module::Build;
+use 5.008;
 
 use strict;
 use warnings;
 
+use Module::Build;
+
+my $module = 'File::Stat::Moose';
+(my $dist = $module) =~ s/::/-/g;
+
 my $build = Module::Build->new(
-    module_name => 'File::Stat::Moose',
-    dist_author => 'Piotr Roszatycki <dexter at debian.org>',
+    module_name => $module,
     license => 'perl',
     requires => {
         'perl'                => 5.008,
@@ -18,6 +22,7 @@
         'Exception::System'   => 0.11,
         'Moose'               => 0,
         'Sub::Exporter'       => 0,
+        'Test::Assert'        => 0.04,
     },
     optional => {
     },
@@ -25,7 +30,6 @@
         'parent'              => 0,
         'Exception::Died'     => 0.04,
         'Exception::Warning'  => 0.03,
-        'Test::Assert'        => 0.04,
         'Test::Unit::Lite'    => 0.11,
     },
     create_makefile_pl => 'traditional',
@@ -35,8 +39,14 @@
         'META.yml', '*.bak', '*.gz', '*.tgz', '*.ppd', '*.deb', '*.bat',
         'Makefile.PL', 'Makefile', 'pm_to_blib', 'README', 'cover_db',
         'Debian_CPANTS.txt',
-        'File-Stat-Moose-*',
+        "$dist-*",
     ],
+    meta_merge => {
+        resources => {
+            bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=$dist",
+            repository => "http://code2.0beta.co.uk/moose/svn/$dist",
+        }
+    },
 );
 
 $build->create_build_script;

Modified: File-Stat-Moose/trunk/Changes
===================================================================
--- File-Stat-Moose/trunk/Changes	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/Changes	2009-01-12 15:10:59 UTC (rev 7294)
@@ -1,10 +1,15 @@
 ------------------------------------------------------------------------
-0.0401 | Piotr Roszatycki <dexter at debian.org> | 2009-01-10
+0.05 | Piotr Roszatycki <dexter at debian.org> | 2009-01-12
 
 Changes:
 
 * File::Stat::Moose:
-  * Attributes "ctime", "atime" and "mtime" returns undef if stat was not
+  * New method "update".
+  * Methods "stat" and "lstat" are deprecared.
+  * Attribute "file" is required.
+  * All attributes are "ro".
+  * New attribute "spec" contains the class name of File::Spec class.
+  * Attributes "atime", "ctime" and "mtime" returns undef if stat was not
     called.
 * MooseX::Types::*:
   * Fix description of modules.

Modified: File-Stat-Moose/trunk/Incompatibilities
===================================================================
--- File-Stat-Moose/trunk/Incompatibilities	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/Incompatibilities	2009-01-12 15:10:59 UTC (rev 7294)
@@ -1,15 +1,32 @@
 ------------------------------------------------------------------------
+0.04 -> 0.05
+
+* Methods "stat" and "lstat" are deprecared.
+  Attribute "file" is required.
+  All attributes are "ro".
+
+  Was:
+
+  my $st = File::Stat::Moose->new;
+  $st->file( "/etc/passwd" );
+  $st->stat;
+
+  Should be:
+
+  my $st = File::Stat::Moose->new( file => "/etc/passwd" );
+
+------------------------------------------------------------------------
 0.03 -> 0.04
 
 * Static methods "stat" and "lstat" was removed.
 
   Was:
-  
+
   my $st1 = File::Stat::Moose->stat( "/etc/passwd" );
   my $st2 = File::Stat::Moose->lstat( "/dev/cdrom" );
-  
+
   Should be:
-  
+
   my $st1 = File::Stat::Moose->new( file => "/etc/passwd", follow => 1 );
   my $st2 = File::Stat::Moose->new( file => "/dev/cdrom" );
 
@@ -17,10 +34,10 @@
   value.
 
   Was:
-  
+
   my $st = File::Stat::Moose->new( file => 'C:\Autoexec.bat' );
   assert_str_equals( '', $st->blksize );
-  
+
   Should be:
 
   my $st = File::Stat::Moose->new( file => 'C:\Autoexec.bat' );

Modified: File-Stat-Moose/trunk/lib/Exception/IO.pm
===================================================================
--- File-Stat-Moose/trunk/lib/Exception/IO.pm	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/lib/Exception/IO.pm	2009-01-12 15:10:59 UTC (rev 7294)
@@ -33,7 +33,7 @@
 use strict;
 use warnings;
 
-our $VERSION = 0.04_01;
+our $VERSION = 0.05;
 
 
 use Exception::Base 0.21 (
@@ -64,8 +64,10 @@
 
 =end umlwiki
 
-=head1 BASE CLASSES
+=head1 INHERITANCE
 
+=head2 Extends
+
 =over
 
 =item *
@@ -100,7 +102,7 @@
 
 =head1 AUTHOR
 
-Piotr Roszatycki E<lt>dexter at debian.orgE<gt>
+Piotr Roszatycki <dexter at debian.org>
 
 =head1 LICENSE
 

Modified: File-Stat-Moose/trunk/lib/File/Stat/Moose.pm
===================================================================
--- File-Stat-Moose/trunk/lib/File/Stat/Moose.pm	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/lib/File/Stat/Moose.pm	2009-01-12 15:10:59 UTC (rev 7294)
@@ -27,23 +27,31 @@
 
 use 5.008;
 use strict;
-use warnings;
+use warnings FATAL => 'all';
 
-our $VERSION = 0.04_01;
+our $VERSION = 0.05;
 
 use Moose;
 
+# Additional types
 use MooseX::Types::OpenHandle;
 use MooseX::Types::CacheFileHandle;
 
+# Run-time Assertions
+use Test::Assert ':assert';
+
+# TRUE/FALSE
 use constant::boolean;
-use Scalar::Util 'weaken';
 
+# atime, ctime, mtime attributes
 use DateTime;
 
+# file => ArrayRef[Str] attribute
+use File::Spec;
 
+
 use Exception::Base (
-    '+ignore_package' => [ __PACKAGE__, 'Sub::Exporter', qr/^Moose::/, qr/^Class::MOP::/ ],
+    '+ignore_package' => [ __PACKAGE__, qr/^File::Spec(::|$)/, 'Sub::Exporter', qr/^Moose::/, qr/^Class::MOP::/ ],
 );
 use Exception::Argument;
 use Exception::IO;
@@ -51,7 +59,7 @@
 
 use overload (
     '@{}' => '_deref_array',
-    fallback => 1
+    fallback => TRUE,
 );
 
 
@@ -62,8 +70,8 @@
         stat => sub {
             sub (;*) {
                 my $st = __PACKAGE__->new(
-                    file => (defined $_[0] ? $_[0] : $_),
-                    follow => 1
+                    file   => (defined $_[0] ? $_[0] : $_),
+                    follow => TRUE,
                 );
                 return wantarray ? @{ $st } : $st;
             };
@@ -73,7 +81,8 @@
         lstat => sub {
             sub (;*) {
                 my $st = __PACKAGE__->new(
-                    file => (defined $_[0] ? $_[0] : $_)
+                    file   => (defined $_[0] ? $_[0] : $_),
+                    follow => FALSE,
                 );
                 return wantarray ? @{ $st } : $st;
             };
@@ -86,24 +95,33 @@
 
 # File which is checked with stat
 has file => (
-    is       => 'rw',
-    isa      => 'Str | FileHandle | CacheFileHandle | OpenHandle',
+    is        => 'ro',
+    isa       => 'Str | ArrayRef[Str] | FileHandle | CacheFileHandle | OpenHandle',
+    required  => TRUE,
+    predicate => 'has_file',
 );
 
 # Follow symlink or read symlink itself
 has follow => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Bool',
     default  => FALSE,
 );
 
 # Speeds up stat on Win32
 has sloppy => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Bool',
     default  => FALSE,
 );
 
+# File::Spec handler
+has spec => (
+    is      => 'rw',
+    isa     => 'ClassName',
+    default => 'File::Spec',
+);
+
 # Numeric informations about a file
 has [ qw{ dev ino mode nlink uid gid rdev size blksize blocks } ] => (
     is       => 'ro',
@@ -122,72 +140,94 @@
         has $attr => (
             is       => 'ro',
             isa      => 'Maybe[DateTime]',
-            lazy     => 1,
+            lazy     => TRUE,
             default  => sub {
                 defined $_[0]->{"_${attr}_epoch"}
                 ? DateTime->from_epoch( epoch => $_[0]->{"_${attr}_epoch"} )
                 : undef
             },
             reader   => $attr,
+            clearer  => "_clear_$attr",
         );
 
     };
 };
 
 
+## no critic (ProhibitBuiltinHomonyms)
+## no critic (RequireArgUnpacking)
+
 # Constructor calls stat method if necessary
 sub BUILD {
     my ($self, $params) = @_;
 
-    # Call stat or lstat if file was provided
-    if (defined $self->{file}) {
-        $self->{follow} ? $self->stat : $self->lstat;
-    };
-    
+    assert_not_null($self->{file}) if ASSERT;
+
+    # Update stat info
+    $self->update;
+
     return TRUE;
 };
 
 
-# Get file status
-sub stat {
-    my ($self, $file) = @_;
+# Call stat or lstat method
+sub update {
+    my $self = shift;
+    Exception::Argument->throw( message => 'Usage: $st->update()' ) if @_ > 0 or not blessed $self;
 
-    Exception::Argument->throw( message => 'Usage: $st->stat()' ) if @_ > 1;
+    assert_not_null($self->{file}) if ASSERT;
 
-    # Clean lazy attributes
+    my $file = $self->{file};
+
+    # Convert array to string
+    if (ref $file eq 'ARRAY') {
+        $file = $self->spec->catfile(@$file);
+    };
+
+    # Clear lazy attributes
     delete @{$self}{ qw{ atime mtime ctime } };
 
     local ${^WIN32_SLOPPY_STAT} = $self->{sloppy};
 
-    delete @{$self}{ qw{ atime mtime ctime } };
+    if ($self->{follow}) {
+        @{$self}{ qw{ dev ino mode nlink uid gid rdev size _atime_epoch _mtime_epoch _ctime_epoch blksize blocks } }
+        = map { defined $_ && $_ eq '' ? undef : $_ }
+          CORE::stat $file or Exception::IO->throw( message => 'Cannot stat' );
+    }
+    else {
+        no warnings 'io';  # lstat() on filehandle
+        @{$self}{ qw{ dev ino mode nlink uid gid rdev size _atime_epoch _mtime_epoch _ctime_epoch blksize blocks } }
+        = map { defined $_ && $_ eq '' ? undef : $_ }
+          CORE::lstat $file or Exception::IO->throw( message => 'Cannot lstat' );
+    };
 
-    @{$self}{ qw{ dev ino mode nlink uid gid rdev size _atime_epoch _mtime_epoch _ctime_epoch blksize blocks } }
-    = map { defined $_ && $_ eq '' ? undef : $_ }
-      CORE::stat $self->{file} or Exception::IO->throw( message => 'Cannot stat' );
-
     return $self;
 };
 
 
-# Get link status
-sub lstat {
-    my ($self, $file) = @_;
+# Deprecated
+sub stat {
+    my ($self) = @_;
 
-    Exception::Argument->throw( message => 'Usage: $st->lstat()' ) if @_ > 1;
+    ## no critic (RequireCarping)
+    warn "Method (File::Stat::Moose->stat) is deprecated. Use constructor (new) and method (update) instead";
 
-    # Clean lazy attributes
-    delete @{$self}{ qw{ atime mtime ctime } };
+    confess "Cannot call method (File::Stat::Moose->stat) attribute (follow) attribute is true value" if $self->follow;
 
-    local ${^WIN32_SLOPPY_STAT} = $self->{sloppy};
+    return $self->update;
+};
 
-    delete @{$self}{ qw{ atime mtime ctime } };
 
-    no warnings 'io';  # lstat() on filehandle
-    @{$self}{ qw{ dev ino mode nlink uid gid rdev size _atime_epoch _mtime_epoch _ctime_epoch blksize blocks } }
-    = map { defined $_ && $_ eq '' ? undef : $_ }
-      CORE::lstat $self->{file} or Exception::IO->throw( message => 'Cannot lstat' );
+# Deprecated
+sub lstat {
+    my ($self) = @_;
 
-    return $self;
+    ## no critic (RequireCarping)
+    warn "Method (File::Stat::Moose->lstat) is deprecated. Use constructor (new) and method (update) instead";
+
+    confess "Cannot call method (File::Stat::Moose->lstat) attribute (follow) attribute is false value" if not $self->follow;
+
+    return $self->update;
 };
 
 
@@ -217,17 +257,18 @@
  File::Stat::Moose
  MooseX::Types::OpenHandle
  MooseX::Types::CacheFileHandle
- <<exception>> Exception::IO     
- <<type>> OpenHandle          
+ <<exception>> Exception::IO
+ <<type>> OpenHandle
  <<type>> CacheFileHandle         ]
 
 = Class Diagram =
 
 [                                File::Stat::Moose
  ----------------------------------------------------------------------------------------
- +file : Str|FileHandle|CacheFileHandle|OpenHandle {rw}
- +follow : Bool {rw}                
- +sloppy : Bool {rw}                
+ +file : Str|ArrayRef[Str]|FileHandle|CacheFileHandle|OpenHandle {ro, required}
+ +follow : Bool {ro}
+ +sloppy : Bool {ro}
+ +spec : ClassName {ro}
  +dev : Maybe[Int] {ro}
  +ino : Maybe[Int] {ro}
  +mode : Maybe[Int] {ro}
@@ -245,10 +286,11 @@
  #_mtime_epoch : Maybe[Int] {ro}
  #_ctime_epoch : Maybe[Int] {ro}
  ----------------------------------------------------------------------------------------
- +stat() : Self
- +lstat() : Self
- <<utility>> +stat( file : Str|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
- <<utility>> +lstat( file : Str|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
+ +update() : Self
+ <<deprecated>> +stat() : Self
+ <<deprecated>> +lstat() : Self
+ <<utility>> +stat( file : Str|ArrayRef[Str]|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
+ <<utility>> +lstat( file : Str|ArrayRef[Str]|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
  -_deref_array() : ArrayRef {overload="@{}"}
                                                                                          ]
 
@@ -262,14 +304,20 @@
 
 =over
 
-=item use File::Stat::Moose 'stat', 'lstat';
+=item stat
 
+=item lstat
+
 Imports C<stat> and/or C<lstat> functions.
 
-=item use File::Stat::Moose ':all';
+  use File::Stat::Moose 'stat', 'lstat';
 
+=item :all
+
 Imports all available symbols.
 
+  use File::Stat::Moose ':all';
+
 =back
 
 =head1 EXCEPTIONS
@@ -290,23 +338,28 @@
 
 =over
 
-=item file : Str|FileHandle|CacheFileHandle|OpenHandle {rw}
+=item file : Str|FileHandle|CacheFileHandle|OpenHandle {ro, required}
 
-Contains the file for check.  The attribute can hold file name or file handler
-or IO object.
+Contains the file for check.  The attribute can hold file name or array
+reference of path components or file handler or IO object.
 
-=item follow : Bool {rw}
+=item follow : Bool {ro}
 
 If the value is true and the I<file> for check is symlink, then follows it
 than checking the symlink itself.
 
-=item sloppy : Bool {rw}
+=item sloppy : Bool {ro}
 
 On Win32 L<perlfunc/stat> needs to open the file to determine the link count
 and update attributes that may have been changed through hard links.  If the
 I<sloppy> is set to true value, L<perlfunc/stat> speeds up by not performing
 this operation.
 
+=item spec : ClassName {ro}
+
+Contains the name of L<File::Spec> class name which converts C<file> attribute
+from array reference to string.
+
 =item dev : Maybe[Int] {ro}
 
 ID of device containing file.  If this value and following has no meaning on
@@ -373,8 +426,7 @@
 functions.  Attributes C<atime>, C<ctime> and C<mtime> are returned as number
 values (Unix timestamp).
 
-  $st = File::Stat::Moose->new;
-  $st->file( '/etc/passwd' );
+  $st = File::Stat::Moose->new( file => '/etc/passwd' );
   @st = @$st;
 
 =back
@@ -385,27 +437,19 @@
 
 =item new( I<args> : Hash ) : Self
 
-Creates the C<File::Stat::Moose> object.
+Creates the C<File::Stat::Moose> object and calls C<update> method.
 
-  $st = File::Stat::Moose->new;
-  $st->file( '/etc/passwd' );
-  print "Size: ", $st->size, "\n";
-
-The C<new> constructor calls C<stat> method if the I<file> attribute is
-defined and I<follow> attribute is a true value or calls C<lstat> method if
-the I<file> attribute is defined and I<follow> attribute is not a true value.
-
 If the I<file> is symlink and the I<follow> is true, it will check the file
 that it refers to.  If the I<follow> is false, it will check the symlink
 itself.
 
-  $st = File::Stat::Moose->new( file=>'/etc/cdrom', follow=>1 );
+  $st = File::Stat::Moose->new( file => '/etc/cdrom', follow => 1 );
   print "Device: ", $st->rdev, "\n";  # check real device, not symlink
 
 The object is dereferenced in array context to the array reference which
 contains the same values as L<perlfunc/stat> function output.
 
-  $st = File::Stat::Moose->new( file=>'/etc/passwd' );
+  $st = File::Stat::Moose->new( file => '/etc/passwd' );
   print "Size: ", $st->size, "\n";  # object's attribute
   print "Size: ", $st->[7], "\n";   # array dereference
 
@@ -415,31 +459,20 @@
 
 =over
 
-=item stat(I<>) : Self
+=item update(I<>) : Self
 
-Calls stat on the file which has been set with C<new> constructor.  It returns
-the object reference.
+Updates all attributes which represent status of file.
 
-  $st = File::Stat::Moose->new;
-  $st->file( '/etc/passwd' );
-  print "Size: ", $st->stat->size, "\n";
+Calls L<perlfunc/stat> function if C<follow> method is true value or
+L<perlfunc/lstat> function otherwise.
 
-=item lstat(I<>) : Self
-
-It is identical to C<stat>, except that if I<file> is a symbolic link, then
-the link itself is checked, not the file that it refers to.
-
-  $st = File::Stat::Moose->new;
-  $st->file( '/dev/cdrom' );
-  print "Size: ", $st->lstat->mode, "\n";
-
 =back
 
 =head1 FUNCTIONS
 
 =over
 
-=item stat( I<file> : Str|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
+=item stat( I<file> : Str|ArrayRef[Str]|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
 
 Calls stat on given I<file>.  If the I<file> is undefined, the C<$_> variable
 is used instead.
@@ -458,7 +491,7 @@
   $st = stat '/etc/passwd';
   @st = @$st;
 
-=item lstat( I<file> : Str|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
+=item lstat( I<file> : Str|ArrayRef[Str]|FileHandle|CacheFileHandle|OpenHandle = $_ ) : Self|Array
 
 It is identical to C<stat>, except that if I<file> is a symbolic link, then
 the link itself is checked, not the file that it refers to.
@@ -493,7 +526,7 @@
 
 =head1 AUTHOR
 
-Piotr Roszatycki E<lt>dexter at debian.orgE<gt>
+Piotr Roszatycki <dexter at debian.org>
 
 =head1 LICENSE
 

Modified: File-Stat-Moose/trunk/lib/MooseX/Types/CacheFileHandle.pm
===================================================================
--- File-Stat-Moose/trunk/lib/MooseX/Types/CacheFileHandle.pm	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/lib/MooseX/Types/CacheFileHandle.pm	2009-01-12 15:10:59 UTC (rev 7294)
@@ -28,7 +28,7 @@
 use strict;
 use warnings;
 
-our $VERSION = 0.04_01;
+our $VERSION = 0.05;
 
 use Moose::Util::TypeConstraints;
 
@@ -60,7 +60,7 @@
 
 =head1 AUTHOR
 
-Piotr Roszatycki E<lt>dexter at debian.orgE<gt>
+Piotr Roszatycki <dexter at debian.org>
 
 =head1 LICENSE
 

Modified: File-Stat-Moose/trunk/lib/MooseX/Types/OpenHandle.pm
===================================================================
--- File-Stat-Moose/trunk/lib/MooseX/Types/OpenHandle.pm	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/lib/MooseX/Types/OpenHandle.pm	2009-01-12 15:10:59 UTC (rev 7294)
@@ -29,7 +29,7 @@
 use strict;
 use warnings;
 
-our $VERSION = 0.04_01;
+our $VERSION = 0.05;
 
 use Moose::Util::TypeConstraints;
 
@@ -61,7 +61,7 @@
 
 =head1 AUTHOR
 
-Piotr Roszatycki E<lt>dexter at debian.orgE<gt>
+Piotr Roszatycki <dexter at debian.org>
 
 =head1 LICENSE
 

Modified: File-Stat-Moose/trunk/t/all_tests.t
===================================================================
--- File-Stat-Moose/trunk/t/all_tests.t	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/t/all_tests.t	2009-01-12 15:10:59 UTC (rev 7294)
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 
-use Test::Unit::Lite 0.10;
+use Test::Unit::Lite 0.11;
 use Test::Assert;
 
 use Exception::Base max_arg_nums => 0, max_arg_len => 200, verbosity => 4;

Modified: File-Stat-Moose/trunk/t/test.pl
===================================================================
--- File-Stat-Moose/trunk/t/test.pl	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/t/test.pl	2009-01-12 15:10:59 UTC (rev 7294)
@@ -19,7 +19,7 @@
     unshift @INC, File::Spec->catdir($cwd, 'lib');
 }
 
-use Test::Unit::Lite 0.10;
+use Test::Unit::Lite 0.11;
 use Test::Assert;
 
 use Exception::Base max_arg_nums => 0, max_arg_len => 200, verbosity => 4;

Modified: File-Stat-Moose/trunk/t/tlib/File/Stat/MooseTest.pm
===================================================================
--- File-Stat-Moose/trunk/t/tlib/File/Stat/MooseTest.pm	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/t/tlib/File/Stat/MooseTest.pm	2009-01-12 15:10:59 UTC (rev 7294)
@@ -33,39 +33,86 @@
     unlink $symlink if $symlink;
 };
 
-sub test_new {
-    my $obj = File::Stat::Moose->new;
+sub test_new_file {
+    my $obj = File::Stat::Moose->new( file => $file );
     assert_isa('File::Stat::Moose', $obj);
-    assert_null($obj->size);
+    {
+        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size blksize blocks }) {
+            assert_matches(qr/^\d+$/, $obj->$attr, $attr) if defined $obj->$attr;
+        };
+    };
+    {
+        foreach my $attr (qw { atime mtime ctime }) {
+            assert_isa('DateTime', $obj->$attr, $attr) if defined $obj->$attr;
+        };
+    };
+    assert_not_equals(0, $obj->size);
 };
 
-sub test_new_file {
-    my $obj = File::Stat::Moose->new( file => $file );
+sub test_new_file_sloppy {
+    my $obj = File::Stat::Moose->new( file => $file, sloppy => TRUE );
     assert_isa('File::Stat::Moose', $obj);
+    {
+        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size blksize blocks }) {
+            assert_matches(qr/^\d+$/, $obj->$attr, $attr) if defined $obj->$attr;
+        };
+    };
+    {
+        foreach my $attr (qw { atime mtime ctime }) {
+            assert_isa('DateTime', $obj->$attr, $attr) if defined $obj->$attr;
+        };
+    };
     assert_not_equals(0, $obj->size);
 };
 
+sub test_new_file_spec {
+    my ($volume, $directories, $filename) = File::Spec->splitpath($file);
+    my @dirs = File::Spec->splitdir($directories);
+    assert_not_null($filename);
+    assert_not_null(@dirs);
+    assert_not_equals('', $filename);
+    assert_not_equals(0, scalar @dirs);
+
+    my $obj = File::Stat::Moose->new( file => [ @dirs, $filename ] );
+    assert_isa('File::Stat::Moose', $obj);
+    assert_not_equals(0, $obj->size);
+};
+
 sub test_new_symlink {
     return unless $symlink;
 
-    my $obj1 = File::Stat::Moose->new(file => $symlink);
+    my $obj1 = File::Stat::Moose->new( file => $symlink );
     assert_isa('File::Stat::Moose', $obj1);
+    {
+        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size blksize blocks }) {
+            assert_matches(qr/^\d+$/, $obj1->$attr, $attr) if defined $obj1->$attr;
+        };
+    };
+    {
+        foreach my $attr (qw { atime mtime ctime }) {
+            assert_isa('DateTime', $obj1->$attr, $attr) if defined $obj1->$attr;
+        };
+    };
     assert_not_equals(0, $obj1->size);
 
-    my $obj2 = File::Stat::Moose->new(file => $symlink, follow => 1);
+    my $obj2 = File::Stat::Moose->new( file => $symlink, follow => 1 );
     assert_isa('File::Stat::Moose', $obj2);
     assert_not_equals(0, $obj2->size);
 
     assert_not_equals($obj1->ino, $obj2->ino);
 };
 
-sub test_new_exception_constraint {
+sub test_new_error_args {
+    assert_raises( qr/is required/, sub {
+        my $obj = File::Stat::Moose->new;
+    } );
+
     assert_raises( qr/does not pass the type constraint/, sub {
         my $obj = File::Stat::Moose->new( file => undef );
     } );
 
     assert_raises( qr/does not pass the type constraint/, sub {
-        my $obj = File::Stat::Moose->new( file => [1, 2, 3] );
+        my $obj = File::Stat::Moose->new( file => \1 );
     } );
 
     assert_raises( qr/does not pass the type constraint/, sub {
@@ -77,7 +124,7 @@
     } );
 };
 
-sub test_new_exception_io {
+sub test_new_error_io {
     assert_raises( ['Exception::IO'], sub {
         my $obj = File::Stat::Moose->new( file => $notexistant );
     } );
@@ -95,147 +142,30 @@
     assert_not_equals(0, $obj->[7]);
 };
 
-sub test_stat {
-    my $obj = File::Stat::Moose->new;
-    assert_isa('File::Stat::Moose', $obj);
-    {
-        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size atime ctime mtime blksize blocks }) {
-            assert_null($obj->$attr, $attr);
-        };
-    };
+sub test_update {
+    my $file = File::Temp->new;
+    assert_isa('File::Temp', $file);
+    $file->autoflush(1);
+    $file->print(1);
 
-    $obj->file($file);
-    assert_equals($file, $obj->file);
+    my $obj = File::Stat::Moose->new( file => $file );
+    assert_equals(1, $obj->size);
 
-    $obj->follow(TRUE);
-    assert_true($obj->follow);
+    $file->print(2);
 
-    $obj->sloppy(FALSE);
-    assert_false($obj->sloppy);
-
-    $obj->stat;
-    {
-        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size blksize blocks }) {
-            assert_matches(qr/^\d+$/, $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-    {
-        foreach my $attr (qw { atime mtime ctime }) {
-            assert_isa('DateTime', $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-    assert_not_equals(0, $obj->size);
+    $obj->update;
+    assert_equals(2, $obj->size);
 };
 
-sub test_stat_sloppy {
-    my $obj = File::Stat::Moose->new;
-    assert_isa('File::Stat::Moose', $obj);
+sub test_update_error_args {
+    my $obj = File::Stat::Moose->new( file => $file );
 
-    $obj->file($file);
-    $obj->follow(TRUE);
-
-    $obj->sloppy(TRUE);
-    assert_true($obj->sloppy);
-
-    $obj->stat;
-    {
-        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size blksize blocks }) {
-            assert_matches(qr/^\d+$/, $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-    {
-        foreach my $attr (qw { atime mtime ctime }) {
-            assert_isa('DateTime', $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-    assert_not_equals(0, $obj->size);
-};
-
-sub test_stat_failure {
-    my $obj = File::Stat::Moose->new;
-    assert_isa('File::Stat::Moose', $obj);
-
-    $obj->file($notexistant);
-    $obj->follow(TRUE);
-
-    assert_raises( ['Exception::IO'], sub {
-        $obj->stat;
-    } );
-
     assert_raises( ['Exception::Argument'], sub {
-        $obj->stat('badargument')
+        File::Stat::Moose->update;
     } );
-};
 
-sub test_lstat {
-    my $obj = File::Stat::Moose->new;
-    assert_isa('File::Stat::Moose', $obj);
-    {
-        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size atime ctime mtime blksize blocks }) {
-            assert_null($obj->$attr, $attr);
-        };
-    };
-
-    $obj->file($file);
-    assert_equals($file, $obj->file);
-
-    $obj->follow(FALSE);
-    assert_false($obj->follow);
-
-    $obj->sloppy(FALSE);
-    assert_false($obj->sloppy);
-
-    $obj->lstat;
-    {
-        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size blksize blocks }) {
-            assert_matches(qr/^\d+$/, $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-    assert_not_equals(0, $obj->size);
-    {
-        foreach my $attr (qw { atime mtime ctime }) {
-            assert_isa('DateTime', $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-};
-
-sub test_lstat_sloppy {
-    my $obj = File::Stat::Moose->new;
-    assert_isa('File::Stat::Moose', $obj);
-
-    $obj->file($file);
-    $obj->follow(FALSE);
-
-    $obj->sloppy(TRUE);
-    assert_true($obj->sloppy);
-
-    $obj->lstat;
-    {
-        foreach my $attr (qw{ dev ino mode nlink uid gid rdev size blksize blocks }) {
-            assert_matches(qr/^\d+$/, $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-    {
-        foreach my $attr (qw { atime mtime ctime }) {
-            assert_isa('DateTime', $obj->$attr, $attr) if defined $obj->$attr;
-        };
-    };
-    assert_not_equals(0, $obj->size);
-};
-
-sub test_lstat_failure {
-    my $obj = File::Stat::Moose->new;
-    assert_isa('File::Stat::Moose', $obj);
-
-    $obj->file($notexistant);
-    $obj->follow(FALSE);
-
-    assert_raises( ['Exception::IO'], sub {
-        $obj->lstat;
-    } );
-
     assert_raises( ['Exception::Argument'], sub {
-        $obj->lstat('badargument');
+        $obj->update(1);
     } );
 };
 

Modified: File-Stat-Moose/trunk/xt/consistent_version_numbers.t
===================================================================
--- File-Stat-Moose/trunk/xt/consistent_version_numbers.t	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/xt/consistent_version_numbers.t	2009-01-12 15:10:59 UTC (rev 7294)
@@ -12,7 +12,7 @@
 
 
 my $last_version = undef;
-find({wanted => \&check_version, no_chdir => 1}, 'blib');
+find({wanted => \&check_version, no_chdir => 1}, 'lib');
 if (! defined $last_version) {
     ## no critic (RequireInterpolationOfMetachars)
     fail('Failed to find any files with $VERSION');

Modified: File-Stat-Moose/trunk/xt/copyright.t
===================================================================
--- File-Stat-Moose/trunk/xt/copyright.t	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/xt/copyright.t	2009-01-12 15:10:59 UTC (rev 7294)
@@ -19,7 +19,7 @@
 my $this_year =
     (localtime)[$LOCALTIME_YEAR_FIELD_NUMBER] + $LOCALTIME_YEAR_OFFSET;
 my $copyrights_found = 0;
-find({wanted => \&check_file, no_chdir => 1}, 'blib');
+find({wanted => \&check_file, no_chdir => 1}, 'lib');
 foreach ( grep { m/^readme/ixms } read_dir(q<.>) ) {
     check_file();
 } # end foreach

Modified: File-Stat-Moose/trunk/xt/perlcriticrc
===================================================================
--- File-Stat-Moose/trunk/xt/perlcriticrc	2009-01-12 06:45:08 UTC (rev 7293)
+++ File-Stat-Moose/trunk/xt/perlcriticrc	2009-01-12 15:10:59 UTC (rev 7294)
@@ -1,16 +1,27 @@
 # local defaults for perlcritic
 severity = 3
 verbose = 4
-exclude = ProhibitBuiltinHomonyms RequireArgUnpacking
 
 [ControlStructures::ProhibitCascadingIfElse]
 max_elsif = 5
 
+[Modules::ProhibitExcessMainComplexity]
+max_mccabe = 30
+
+[NamingConventions::ProhibitAmbiguousNames]
+forbid = abstract contract get no record set
+
 [RegularExpressions::ProhibitComplexRegexes]
 max_characters = 70
 
 [RegularExpressions::RequireExtendedFormatting]
 minimum_regex_length_to_complain_about = 75
 
+[Subroutines::ProhibitExcessComplexity]
+max_mccabe = 40
+
+[TestingAndDebugging::ProhibitNoStrict]
+allow = refs subs vars
+
 [TestingAndDebugging::ProhibitNoWarnings]
-allow = io
+allow = ambiguous bareword closed closure debugging deprecated digit exec exiting glob inplace internal io layer malloc misc newline numeric once overflow pack parenthesis pipe portable precedence printf prototype qw recursion redefine regexp reserved semicolon severe signal substr syntax taint threads uninitialized unopened unpack untie utf8 void y2k




More information about the Moose-commits mailing list