Hello community, here is the log from the commit of package perl-Path-Tiny for openSUSE:Factory checked in at 2013-12-10 17:44:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Path-Tiny (Old) and /work/SRC/openSUSE:Factory/.perl-Path-Tiny.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Path-Tiny" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Path-Tiny/perl-Path-Tiny.changes 2013-10-21 15:14:23.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Path-Tiny.new/perl-Path-Tiny.changes 2013-12-10 17:44:42.000000000 +0100 @@ -1,0 +2,24 @@ +Mon Dec 9 13:31:53 UTC 2013 - [email protected] + +- update to 0.047 + - Revised locking tests for portability again: locks are now tested + from a separate process + - Fixed child path construction against the root path. + - Fixed t/00-report-prereqs.t for use with older versions of + CPAN::Meta::Requirements + - When 'realpath' can't be resolved (because intermediate directories + don't exist), the exception now explains the error clearly instead of + complaining about path() needing a defined, positive-length argument. + - Removes duplicate test dependency on File::Spec that triggers + a CPAN.pm bug + - When using 'filehandle' to request a locked handle that truncates an + existing file and has a binmode starting with ":unix", this fixes a + bug where pseudo-layers weren't being cleared properly. + - The 'filehandle' method now offers an option to return locked handles + based on the file mode. Input-output methods now rely on this + feature internally. Truncating file modes defer truncation until + after an exclusive lock is acquired. + - The 'filehandle' method now respects default encoding set by + the caller's open pragma. + +------------------------------------------------------------------- Old: ---- Path-Tiny-0.038.tar.gz New: ---- Path-Tiny-0.047.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Path-Tiny.spec ++++++ --- /var/tmp/diff_new_pack.SdoupN/_old 2013-12-10 17:44:43.000000000 +0100 +++ /var/tmp/diff_new_pack.SdoupN/_new 2013-12-10 17:44:43.000000000 +0100 @@ -17,7 +17,7 @@ Name: perl-Path-Tiny -Version: 0.038 +Version: 0.047 Release: 0 %define cpan_name Path-Tiny Summary: File path utility ++++++ Path-Tiny-0.038.tar.gz -> Path-Tiny-0.047.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/Changes new/Path-Tiny-0.047/Changes --- old/Path-Tiny-0.038/Changes 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/Changes 2013-11-26 21:11:22.000000000 +0100 @@ -1,5 +1,94 @@ Revision history for Path-Tiny +0.047 2013-11-26 15:11:13 America/New_York + + [FIXED] + + - Previous lock testing fixes broke on Windows (sigh); now fixed, + I hope. + +0.046 2013-11-22 17:07:24 America/New_York + + [FIXED] + + - Revised locking tests for portability again: locks are now tested + from a separate process + +0.045 2013-11-22 15:28:50 America/New_York + + [FIXED] + + - Fixed locking test on AIX + +0.044 2013-10-17 17:00:41 America/New_York + + [FIXED] + + - Fixed child path construction against the root path. + + - Fixed path construction when a relative volume is provided as the + first argument on Windows; e.g. path("C:", "lib") must be like + path("C:lib"), not path("C:/lib"). + + - On AIX, shared locking is replaced by exclusive locking on a R/W + filehandle, as locking read handles is not supported + +0.043 2013-10-14 06:24:06 America/New_York + + [CHANGED] + + - Calling 'absolute' on Windows will add the volume if it is missing + (E.g. "/foo" will become "C:/foo"). This matches the behavior + of File::Spec->rel2abs. + + [FIXED] + + - Fixed t/00-report-prereqs.t for use with older versions of + CPAN::Meta::Requirements + +0.042 2013-10-13 11:02:02 America/New_York + + [FIXED] + + - When 'realpath' can't be resolved (because intermediate directories + don't exist), the exception now explains the error clearly instead of + complaining about path() needing a defined, positive-length argument. + + - On Windows, fixed resolution of relative paths with a volume. + E.g. "C:foo" is now correctly translated into getdcwd on "C:" + plus "foo". + +0.041 2013-10-11 08:56:31 America/New_York + + [FIXES] + + - Removes duplicate test dependency on File::Spec that triggers + a CPAN.pm bug + +0.040 2013-10-08 22:01:50 America/New_York + + [FIXES] + + - Fixed broken locking test on *bsd + + - When using 'filehandle' to request a locked handle that truncates an + existing file and has a binmode starting with ":unix", this fixes a + bug where pseudo-layers weren't being cleared properly. + +0.039 2013-10-08 16:39:23 America/New_York + + [ADDITIONS] + + - The 'filehandle' method now offers an option to return locked handles + based on the file mode. Input-output methods now rely on this + feature internally. Truncating file modes defer truncation until + after an exclusive lock is acquired. + + [FIXES] + + - The 'filehandle' method now respects default encoding set by + the caller's open pragma. + 0.038 2013-10-01 18:20:05 America/New_York [ADDITIONS] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/MANIFEST new/Path-Tiny-0.047/MANIFEST --- old/Path-Tiny-0.038/MANIFEST 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/MANIFEST 2013-11-26 21:11:22.000000000 +0100 @@ -10,7 +10,6 @@ dist.ini lib/Path/Tiny.pm perlcritic.rc -t/00-compile.t t/00-report-prereqs.t t/README t/basic.t @@ -22,6 +21,7 @@ t/input_output.t t/input_output_no_UU.t t/lib/TestUtils.pm +t/locking.t t/mkpath.t t/normalize.t t/overloading.t @@ -31,6 +31,7 @@ t/temp.t t/zzz-spec.t tidyall.ini +xt/author/00-compile.t xt/author/critic.t xt/author/pod-spell.t xt/release/distmeta.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/META.json new/Path-Tiny-0.047/META.json --- old/Path-Tiny-0.038/META.json 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/META.json 2013-11-26 21:11:22.000000000 +0100 @@ -4,7 +4,7 @@ "David Golden <[email protected]>" ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 4.300039, CPAN::Meta::Converter version 2.132620", + "generated_by" : "Dist::Zilla version 5.006, CPAN::Meta::Converter version 2.132830", "license" : [ "apache_2_0" ], @@ -32,8 +32,19 @@ }, "develop" : { "requires" : { + "Dist::Zilla" : "5.006", + "Dist::Zilla::Plugin::MakeMaker" : "0", + "Dist::Zilla::Plugin::OnlyCorePrereqs" : "0", + "Dist::Zilla::Plugin::Prereqs" : "0", + "Dist::Zilla::Plugin::RemovePrereqs" : "0", + "Dist::Zilla::PluginBundle::DAGOLDEN" : "0.055", + "File::Spec" : "0", + "File::Temp" : "0", + "IO::Handle" : "0", + "IPC::Open3" : "0", "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Meta" : "0", + "Test::More" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } @@ -52,7 +63,7 @@ "File::Copy" : "0", "File::Path" : "2.07", "File::Spec" : "3.40", - "File::Temp" : "0.18", + "File::Temp" : "0.19", "File::stat" : "0", "constant" : "0", "if" : "0", @@ -64,17 +75,16 @@ }, "test" : { "recommends" : { + "CPAN::Meta" : "0", + "CPAN::Meta::Requirements" : "0", "Test::FailWarnings" : "0" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Basename" : "0", - "File::Spec" : "0", "File::Spec::Functions" : "0", "File::Spec::Unix" : "0", "File::Temp" : "0.19", - "IO::Handle" : "0", - "IPC::Open3" : "0", "List::Util" : "0", "Test::More" : "0.96", "lib" : "0", @@ -85,15 +95,15 @@ "provides" : { "Path::Tiny" : { "file" : "lib/Path/Tiny.pm", - "version" : "0.038" + "version" : "0.047" }, "Path::Tiny::Error" : { "file" : "lib/Path/Tiny.pm", - "version" : "0.038" + "version" : "0.047" }, "flock" : { "file" : "lib/Path/Tiny.pm", - "version" : "0.038" + "version" : "0.047" } }, "release_status" : "stable", @@ -108,7 +118,7 @@ "web" : "https://github.com/dagolden/Path-Tiny" } }, - "version" : "0.038", + "version" : "0.047", "x_authority" : "cpan:DAGOLDEN", "x_contributors" : [ "Chris Williams <[email protected]>", @@ -116,12 +126,14 @@ "Gabor Szabo <[email protected]>", "Gabriel Andrade <[email protected]>", "George Hartzell <[email protected]>", + "Geraud Continsouzas <[email protected]>", "Goro Fuji <[email protected]>", "Karen Etheridge <[email protected]>", "Keedi Kim <[email protected]>", "Martin Kjeldsen <[email protected]>", "Michael G. Schwern <[email protected]>", - "Toby Inkster <[email protected]>" + "Toby Inkster <[email protected]>", + "\uae40\ub3c4\ud615 - Keedi Kim <[email protected]>" ] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/META.yml new/Path-Tiny-0.047/META.yml --- old/Path-Tiny-0.038/META.yml 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/META.yml 2013-11-26 21:11:22.000000000 +0100 @@ -5,12 +5,9 @@ build_requires: ExtUtils::MakeMaker: 0 File::Basename: 0 - File::Spec: 0 File::Spec::Functions: 0 File::Spec::Unix: 0 File::Temp: 0.19 - IO::Handle: 0 - IPC::Open3: 0 List::Util: 0 Test::More: 0.96 lib: 0 @@ -18,7 +15,7 @@ configure_requires: ExtUtils::MakeMaker: 6.17 dynamic_config: 0 -generated_by: 'Dist::Zilla version 4.300039, CPAN::Meta::Converter version 2.132620' +generated_by: 'Dist::Zilla version 5.006, CPAN::Meta::Converter version 2.132830' license: apache meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -35,13 +32,13 @@ provides: Path::Tiny: file: lib/Path/Tiny.pm - version: 0.038 + version: 0.047 Path::Tiny::Error: file: lib/Path/Tiny.pm - version: 0.038 + version: 0.047 flock: file: lib/Path/Tiny.pm - version: 0.038 + version: 0.047 recommends: Unicode::UTF8: 0.58 requires: @@ -54,7 +51,7 @@ File::Copy: 0 File::Path: 2.07 File::Spec: 3.40 - File::Temp: 0.18 + File::Temp: 0.19 File::stat: 0 constant: 0 if: 0 @@ -66,7 +63,7 @@ bugtracker: https://github.com/dagolden/Path-Tiny/issues homepage: https://github.com/dagolden/Path-Tiny repository: https://github.com/dagolden/Path-Tiny.git -version: 0.038 +version: 0.047 x_authority: cpan:DAGOLDEN x_contributors: - 'Chris Williams <[email protected]>' @@ -74,9 +71,11 @@ - 'Gabor Szabo <[email protected]>' - 'Gabriel Andrade <[email protected]>' - 'George Hartzell <[email protected]>' + - 'Geraud Continsouzas <[email protected]>' - 'Goro Fuji <[email protected]>' - 'Karen Etheridge <[email protected]>' - 'Keedi Kim <[email protected]>' - 'Martin Kjeldsen <[email protected]>' - 'Michael G. Schwern <[email protected]>' - 'Toby Inkster <[email protected]>' + - '김도형 - Keedi Kim <[email protected]>' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/Makefile.PL new/Path-Tiny-0.047/Makefile.PL --- old/Path-Tiny-0.038/Makefile.PL 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/Makefile.PL 2013-11-26 21:11:22.000000000 +0100 @@ -29,7 +29,7 @@ "File::Copy" => 0, "File::Path" => "2.07", "File::Spec" => "3.40", - "File::Temp" => "0.18", + "File::Temp" => "0.19", "File::stat" => 0, "constant" => 0, "if" => 0, @@ -40,48 +40,53 @@ "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Basename" => 0, - "File::Spec" => 0, "File::Spec::Functions" => 0, "File::Spec::Unix" => 0, "File::Temp" => "0.19", - "IO::Handle" => 0, - "IPC::Open3" => 0, "List::Util" => 0, "Test::More" => "0.96", "lib" => 0, "open" => 0 }, - "VERSION" => "0.038", + "VERSION" => "0.047", "test" => { "TESTS" => "t/*.t" } ); -unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { - my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; - my $br = $WriteMakefileArgs{BUILD_REQUIRES}; - for my $mod ( keys %$tr ) { - if ( exists $br->{$mod} ) { - $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; - } - else { - $br->{$mod} = $tr->{$mod}; - } - } -} +my %FallbackPrereqs = ( + "Carp" => 0, + "Cwd" => 0, + "Digest" => "1.03", + "Digest::SHA" => "5.45", + "Exporter" => "5.57", + "ExtUtils::MakeMaker" => 0, + "Fcntl" => 0, + "File::Basename" => 0, + "File::Copy" => 0, + "File::Path" => "2.07", + "File::Spec" => "3.40", + "File::Spec::Functions" => 0, + "File::Spec::Unix" => 0, + "File::Temp" => "0.19", + "File::stat" => 0, + "List::Util" => 0, + "Test::More" => "0.96", + "constant" => 0, + "if" => 0, + "lib" => 0, + "open" => 0, + "overload" => 0, + "strict" => 0, + "warnings" => 0 +); -unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { - my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; - my $pp = $WriteMakefileArgs{PREREQ_PM}; - for my $mod ( keys %$br ) { - if ( exists $pp->{$mod} ) { - $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; - } - else { - $pp->{$mod} = $br->{$mod}; - } - } + +unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { + delete $WriteMakefileArgs{TEST_REQUIRES}; + delete $WriteMakefileArgs{BUILD_REQUIRES}; + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/README new/Path-Tiny-0.047/README --- old/Path-Tiny-0.038/README 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/README 2013-11-26 21:11:22.000000000 +0100 @@ -2,7 +2,7 @@ Path::Tiny - File path utility VERSION - version 0.038 + version 0.047 SYNOPSIS use Path::Tiny; @@ -57,7 +57,7 @@ the object gives you back the path (after some clean up). File input/output methods "flock" handles before reading or writing, as - appropriate. + appropriate (if supported by the platform). The *_utf8 methods ("slurp_utf8", "lines_utf8", etc.) operate in raw mode without CRLF translation. Installing Unicode::UTF8 0.58 or later @@ -150,15 +150,19 @@ $abs = path("foo/bar")->absolute; $abs = path("foo/bar")->absolute("/tmp"); - Returns a new "Path::Tiny" object with an absolute path. Unless an - argument is given, the current directory is used as the absolute base - path. The argument must be absolute or you won't get an absolute result. + Returns a new "Path::Tiny" object with an absolute path (or itself if + already absolute). Unless an argument is given, the current directory is + used as the absolute base path. The argument must be absolute or you + won't get an absolute result. This will not resolve upward directories ("foo/../bar") unless "canonpath" in File::Spec would normally do so on your platform. If you need them resolved, you must call the more expensive "realpath" method instead. + On Windows, an absolute path without a volume component will have it + added based on the current drive. + append, append_raw, append_utf8 path("foo.txt")->append(@data); path("foo.txt")->append(\@data); @@ -243,11 +247,18 @@ filehandle $fh = path("/tmp/foo.txt")->filehandle($mode, $binmode); + $fh = path("/tmp/foo.txt")->filehandle({ locked => 1 }, $mode, $binmode); Returns an open file handle. The $mode argument must be a Perl-style read/write mode string ("<" ,">", "<<", etc.). If a $binmode is given, it is set during the "open" call. + An optional hash reference may be used to pass options. The only option + is "locked". If true, handles opened for writing, appending or + read-write are locked with "LOCK_EX"; otherwise, they are locked with + "LOCK_SH". When using "locked", ">" or "+>" modes will delay truncation + until after the lock is acquired. + See "openr", "openw", "openrw", and "opena" for sugar. is_absolute, is_relative @@ -363,6 +374,15 @@ have "open*_raw" and "open*_utf8" equivalents that use ":raw" and ":raw:encoding(UTF-8)", respectively. + An optional hash reference may be used to pass options. The only option + is "locked". If true, handles opened for writing, appending or + read-write are locked with "LOCK_EX"; otherwise, they are locked for + "LOCK_SH". + + $fh = path("foo.txt")->openrw_utf8( { locked => 1 } ); + + See "filehandle" for more on locking. + parent $parent = path("foo/bar/baz")->parent; # foo/bar $parent = path("foo/wibble.txt")->parent; # foo @@ -382,6 +402,11 @@ directory parts resolved using Cwd's "realpath". Compared to "absolute", this is more expensive as it must actually consult the filesystem. + If the path can't be resolved (e.g. if it includes directories that + don't exist), an exception will be thrown: + + $real = path("doesnt_exist/foo")->realpath; # dies + relative $rel = path("/tmp/foo/bar")->relative("/tmp"); # foo/bar @@ -498,20 +523,26 @@ The object will be a hash reference with the following fields: - * "op" â a description of the operation, usually function call and - any extra info + * "op" — a description of the operation, usually function call and any + extra info - * "file" â the file or directory relating to the error + * "file" — the file or directory relating to the error - * "err" â hold $! at the time the error was thrown + * "err" — hold $! at the time the error was thrown - * "msg" â a string combining the above data and a Carp-like short + * "msg" — a string combining the above data and a Carp-like short stack trace Exception objects will stringify as the "msg" field. CAVEATS - NFS and BSD + File locking + If flock is not supported on a platform, it will not be used, even if + locking is requested. + + See additional caveats below. + + NFS and BSD On BSD, Perl's flock implementation may not work to lock files on an NFS filesystem. Path::Tiny has some heuristics to detect this and will warn once and let you continue in an unsafe mode. If you want this failure to @@ -519,6 +550,11 @@ use warnings FATAL => 'flock'; + AIX and locking + AIX requires a write handle for locking. Therefore, calls that normally + open a read handle and take a shared lock instead will open a read-write + handle and take an exclusive lock. + utf8 vs UTF-8 All the *_utf8 methods use ":encoding(UTF-8)" -- either as ":unix:encoding(UTF-8)" (unbuffered) or ":raw:encoding(UTF-8)" @@ -547,15 +583,16 @@ Default IO layers and the open pragma If you have Perl 5.10 or later, file input/output methods ("slurp", - "spew", etc.) and high-level handle opening methods ( "openr", "openw", - etc. but not "filehandle") respect default encodings set by the "-C" + "spew", etc.) and high-level handle opening methods ( "filehandle", + "openr", "openw", etc. ) respect default encodings set by the "-C" switch or lexical open settings of the caller. For UTF-8, this is almost certainly slower than using the dedicated "_utf8" methods if you have Unicode::UTF8. TYPE CONSTRAINTS AND COERCION A standard MooseX::Types library is available at - MooseX::Types::Path::Tiny. + MooseX::Types::Path::Tiny. A Type::Tiny equivalent is available as + Types::Path::Tiny. SEE ALSO These are other file/path utilities, which may offer a different feature @@ -605,6 +642,8 @@ * George Hartzell <[email protected]> + * Geraud Continsouzas <[email protected]> + * Goro Fuji <[email protected]> * Karen Etheridge <[email protected]> @@ -617,6 +656,8 @@ * Toby Inkster <[email protected]> + * 김도형 - Keedi Kim <[email protected]> + COPYRIGHT AND LICENSE This software is Copyright (c) 2013 by David Golden. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/cpanfile new/Path-Tiny-0.047/cpanfile --- old/Path-Tiny-0.038/cpanfile 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/cpanfile 2013-11-26 21:11:22.000000000 +0100 @@ -7,7 +7,7 @@ requires "File::Copy" => "0"; requires "File::Path" => "2.07"; requires "File::Spec" => "3.40"; -requires "File::Temp" => "0.18"; +requires "File::Temp" => "0.19"; requires "File::stat" => "0"; requires "constant" => "0"; requires "if" => "0"; @@ -20,12 +20,9 @@ on 'test' => sub { requires "ExtUtils::MakeMaker" => "0"; requires "File::Basename" => "0"; - requires "File::Spec" => "0"; requires "File::Spec::Functions" => "0"; requires "File::Spec::Unix" => "0"; requires "File::Temp" => "0.19"; - requires "IO::Handle" => "0"; - requires "IPC::Open3" => "0"; requires "List::Util" => "0"; requires "Test::More" => "0.96"; requires "lib" => "0"; @@ -33,6 +30,8 @@ }; on 'test' => sub { + recommends "CPAN::Meta" => "0"; + recommends "CPAN::Meta::Requirements" => "0"; recommends "Test::FailWarnings" => "0"; }; @@ -41,8 +40,19 @@ }; on 'develop' => sub { + requires "Dist::Zilla" => "5.006"; + requires "Dist::Zilla::Plugin::MakeMaker" => "0"; + requires "Dist::Zilla::Plugin::OnlyCorePrereqs" => "0"; + requires "Dist::Zilla::Plugin::Prereqs" => "0"; + requires "Dist::Zilla::Plugin::RemovePrereqs" => "0"; + requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.055"; + requires "File::Spec" => "0"; + requires "File::Temp" => "0"; + requires "IO::Handle" => "0"; + requires "IPC::Open3" => "0"; requires "Pod::Coverage::TrustPod" => "0"; requires "Test::CPAN::Meta" => "0"; + requires "Test::More" => "0"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/dist.ini new/Path-Tiny-0.047/dist.ini --- old/Path-Tiny-0.038/dist.ini 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/dist.ini 2013-11-26 21:11:22.000000000 +0100 @@ -5,8 +5,9 @@ copyright_year = 2013 [@DAGOLDEN] -:version = 0.050 +:version = 0.055 -remove = MakeMaker +stopwords = AIX stopwords = BENCHMARKING stopwords = CRLF stopwords = SHA diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/lib/Path/Tiny.pm new/Path-Tiny-0.047/lib/Path/Tiny.pm --- old/Path-Tiny-0.038/lib/Path/Tiny.pm 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/lib/Path/Tiny.pm 2013-11-26 21:11:22.000000000 +0100 @@ -4,9 +4,10 @@ package Path::Tiny; # ABSTRACT: File path utility -our $VERSION = '0.038'; # VERSION +our $VERSION = '0.047'; # VERSION # Dependencies +use Config; use Exporter 5.57 (qw/import/); use File::Spec 3.40 (); use Carp (); @@ -15,12 +16,14 @@ our @EXPORT_OK = qw/cwd rootdir tempfile tempdir/; use constant { - PATH => 0, - CANON => 1, - VOL => 2, - DIR => 3, - FILE => 4, - TEMP => 5, + PATH => 0, + CANON => 1, + VOL => 2, + DIR => 3, + FILE => 4, + TEMP => 5, + IS_BSD => ( scalar $^O =~ /bsd$/ ), + IS_WIN32 => ( $^O eq 'MSWin32' ), }; use overload ( @@ -29,10 +32,6 @@ fallback => 1, ); -my $IS_BSD; - -BEGIN { $IS_BSD = $^O =~ /bsd$/ } - # if cloning, threads should already be loaded, but Win32 pseudoforks # don't do that so we have to be sure it's loaded anyway my $TID = 0; # for thread safe atomic writes @@ -45,43 +44,48 @@ eval { require Unicode::UTF8; Unicode::UTF8->VERSION(0.58); 1 }; } +my $HAS_FLOCK = $Config{d_flock} || $Config{d_fcntl_can_lock} || $Config{d_lockf}; + # notions of "root" directories differ on Win32: \\server\dir\ or C:\ or \ my $SLASH = qr{[\\/]}; -my $NOTSLASH = qr{[^\\/]+}; +my $NOTSLASH = qr{[^\\/]}; my $DRV_VOL = qr{[a-z]:}i; -my $UNC_VOL = qr{$SLASH $SLASH $NOTSLASH $SLASH $NOTSLASH}x; +my $UNC_VOL = qr{$SLASH $SLASH $NOTSLASH+ $SLASH $NOTSLASH+}x; my $WIN32_ROOT = qr{(?: $UNC_VOL $SLASH | $DRV_VOL $SLASH | $SLASH )}x; -sub _normalize_win32_path { - my ($path) = @_; - if ( $path =~ /^$DRV_VOL$/ ) { - require Cwd; - my $fullpath = Cwd::getdcwd($path); # C: -> C:\some\cwd - # getdcwd on non-existent drive returns empty string - $path = length $fullpath ? $fullpath : $path . "/"; - } - elsif ( $path =~ /^$UNC_VOL$/ ) { - $path .= "/"; # canonpath currently strips it and we want it - } - # hack to make splitpath give us a basename; might not be necessary - # since canonpath should do this for non-root paths, but I don't trust it - $path =~ s{/$}{} if $path !~ /^$WIN32_ROOT$/; +sub _win32_vol { + my ( $path, $drv ) = @_; + require Cwd; + my $dcwd = Cwd::getdcwd($drv); # C: -> C:\some\cwd + # getdcwd on non-existent drive returns empty string + # so just use the original drive Z: -> Z: + $dcwd = "$drv" unless length $dcwd; + # normalize dwcd to end with a slash: might be C:\some\cwd or D:\ or Z: + $dcwd =~ s{$SLASH?$}{/}; + # make the path absolute with dcwd + $path =~ s{^$DRV_VOL}{$dcwd}; return $path; } +# This is a string test for before we have the object; see is_rootdir for well-formed +# object test +sub _is_root { + return IS_WIN32() ? ( $_[0] =~ /^$WIN32_ROOT$/ ) : ( $_[0] eq '/' ); +} + # flock doesn't work on NFS on BSD. Since program authors often can't control # or detect that, we warn once instead of being fatal if we can detect it and # people who need it strict can fatalize the 'flock' category #<<< No perltidy -{ package flock; use if $IS_BSD, 'warnings::register' } +{ package flock; use if Path::Tiny::IS_BSD(), 'warnings::register' } #>>> my $WARNED_BSD_NFS = 0; sub _throw { my ( $self, $function, $file ) = @_; - if ( $IS_BSD + if ( IS_BSD() && $function =~ /^flock/ && $! =~ /operation not supported/i && !warnings::fatal_enabled('flock') ) @@ -126,22 +130,42 @@ my $path = shift; Carp::croak("path() requires a defined, positive-length argument") unless defined $path && length $path; - # join stringifies any objects, too, which is handy :-) - $path = join( "/", ( $path eq '/' ? "" : $path ), @_ ) if @_; + + # stringify initial path + $path = "$path"; + + # expand relative volume paths on windows; put trailing slash on UNC root + if ( IS_WIN32() ) { + $path = _win32_vol( $path, $1 ) if $path =~ m{^($DRV_VOL)(?:$NOTSLASH|$)}; + $path .= "/" if $path =~ m{^$UNC_VOL$}; + } + + # concatenate more arguments (stringifies any objects, too) + if (@_) { + $path .= ( _is_root($path) ? "" : "/" ) . join( "/", @_ ); + } + + # canonicalize paths my $cpath = $path = File::Spec->canonpath($path); # ugh, but probably worth it - if ( $^O eq 'MSWin32' ) { - $path = _normalize_win32_path($path); + $path =~ tr[\\][/]; # unix convention enforced + $path .= "/" if IS_WIN32() && $path =~ m{^$UNC_VOL$}; # canonpath strips it + + # hack to make splitpath give us a basename; root paths must always have + # a trailing slash, but other paths must not + if ( _is_root($path) ) { + $path =~ s{/?$}{/}; } else { - # hack to make splitpath give us a basename; might not be necessary - # since canonpath should do this for non-root paths, but I don't trust it - $path =~ s{/$}{} if $path ne '/'; - } - $path =~ tr[\\][/]; # unix convention enforced - if ( $path =~ m{^(~[^/]*).*} ) { # expand a tilde - my ($homedir) = glob($1); # glob without list context == heisenbug! + $path =~ s{/$}{}; + } + + # do any tilde expansions + if ( $path =~ m{^(~[^/]*).*} ) { + my ($homedir) = glob($1); # glob without list context == heisenbug! $path =~ s{^(~[^/]*)}{$homedir}; } + + # and we're finally done bless [ $path, $cpath ], __PACKAGE__; } @@ -213,10 +237,24 @@ sub absolute { my ( $self, $base ) = @_; - return $self if $self->is_absolute; + # absolute paths handled differently by OS + if (IS_WIN32) { + return $self if length $self->volume; + # add missing volume + if ( $self->is_absolute ) { + require Cwd; + my ($drv) = Cwd::getdcwd() =~ /^($DRV_VOL | $UNC_VOL)/x; + return path( $drv . $self->[PATH] ); + } + } + else { + return $self if $self->is_absolute; + } + + # relative path on any OS require Cwd; - return path( join "/", ( defined($base) ? $base : Cwd::getcwd() ), $_[0]->[PATH] ); + return path( ( defined($base) ? $base : Cwd::getcwd() ), $_[0]->[PATH] ); } @@ -226,17 +264,8 @@ $args = _get_args( $args, qw/binmode/ ); my $binmode = $args->{binmode}; $binmode = ( ( caller(0) )[10] || {} )->{'open>'} unless defined $binmode; - my $fh = $self->filehandle( ">>", $binmode ); - - require Fcntl; - flock( $fh, Fcntl::LOCK_EX() ) or $self->_throw('flock (LOCK_EX)'); - - # Ensure we're at the end after the lock - seek( $fh, 0, Fcntl::SEEK_END() ) or $self->_throw('seek'); - + my $fh = $self->filehandle( { locked => 1 }, ">>", $binmode ); print {$fh} map { ref eq 'ARRAY' ? @$_ : $_ } @data; - - # For immediate flush close $fh or $self->_throw('close'); } @@ -266,8 +295,7 @@ sub child { my ( $self, @parts ) = @_; - my $path = $self->[PATH]; - return path( join( "/", ( $path eq '/' ? "" : $path ), @parts ) ); + return path( $self->[PATH], @parts ); } @@ -288,7 +316,7 @@ Carp::croak("Invalid argument '$filter' for children()"); } - return map { path( $self->[PATH] . "/$_" ) } @children; + return map { path( $self->[PATH], $_ ) } @children; } @@ -327,13 +355,66 @@ # like ":unix" actually stop perlio/crlf from being added sub filehandle { - my ( $self, $opentype, $binmode ) = @_; + my ( $self, @args ) = @_; + my $args = ( @args && ref $args[0] eq 'HASH' ) ? shift @args : {}; + $args = _get_args( $args, qw/locked/ ); + my ( $opentype, $binmode ) = @args; + $opentype = "<" unless defined $opentype; - $binmode = "" unless defined $binmode; + Carp::croak("Invalid file mode '$opentype'") + unless grep { $opentype eq $_ } qw/< +< > +> >> +>>/; + + $binmode = ( ( caller(0) )[10] || {} )->{ 'open' . substr( $opentype, -1, 1 ) } + unless defined $binmode; + $binmode = "" unless defined $binmode; + + my ( $fh, $lock, $trunc ); + if ( $HAS_FLOCK && $args->{locked} ) { + require Fcntl; + # truncating file modes shouldn't truncate until lock acquired + if ( grep { $opentype eq $_ } qw( > +> ) ) { + # sysopen in write mode without truncation + my $flags = $opentype eq ">" ? Fcntl::O_WRONLY() : Fcntl::O_RDWR(); + $flags |= Fcntl::O_CREAT(); + sysopen( $fh, $self->[PATH], $flags ) or $self->_throw("sysopen"); + + # fix up the binmode since sysopen() can't specify layers like + # open() and binmode() can't start with just :unix like open() + if ( $binmode =~ s/^:unix// ) { + # eliminate pseudo-layers + binmode( $fh, ":raw" ) or $self->_throw("binmode (:raw)"); + # strip off real layers until only :unix is left + while ( 1 < ( my $layers =()= PerlIO::get_layers( $fh, output => 1 ) ) ) { + binmode( $fh, ":pop" ) or $self->_throw("binmode (:pop)"); + } + } + + # apply any remaining binmode layers + if ( length $binmode ) { + binmode( $fh, $binmode ) or $self->_throw("binmode ($binmode)"); + } + + # ask for lock and truncation + $lock = Fcntl::LOCK_EX(); + $trunc = 1; + } + elsif ( $^O eq 'aix' && $opentype eq "<" ) { + # AIX can only lock write handles, so upgrade to RW and LOCK_EX + $opentype = "+<"; + $lock = Fcntl::LOCK_EX(); + } + else { + $lock = $opentype eq "<" ? Fcntl::LOCK_SH() : Fcntl::LOCK_EX(); + } + } - my $mode = $opentype . $binmode; - my $fh; - open $fh, $mode, $self->[PATH] or $self->_throw('open ($mode)'); + unless ($fh) { + my $mode = $opentype . $binmode; + open $fh, $mode, $self->[PATH] or $self->_throw("open ($mode)"); + } + + do { flock( $fh, $lock ) or $self->_throw("flock ($lock)") } if $lock; + do { truncate( $fh, 0 ) or $self->_throw("truncate") } if $trunc; return $fh; } @@ -392,9 +473,7 @@ my $args = _get_args( shift, qw/binmode chomp count/ ); my $binmode = $args->{binmode}; $binmode = ( ( caller(0) )[10] || {} )->{'open<'} unless defined $binmode; - my $fh = $self->filehandle( "<", $binmode ); - require Fcntl; - flock( $fh, Fcntl::LOCK_SH() ) or $self->_throw('flock (LOCK_SH)'); + my $fh = $self->filehandle( { locked => 1 }, "<", $binmode ); my $chomp = $args->{chomp}; # XXX more efficient to read @lines then chomp(@lines) vs map? if ( $args->{count} ) { @@ -465,6 +544,7 @@ } +# map method names to corresponding open mode my %opens = ( opena => ">>", openr => "<", @@ -476,13 +556,26 @@ no strict 'refs'; # must check for lexical IO mode hint *{$k} = sub { - my ( $self, $binmode ) = @_; + my ( $self, @args ) = @_; + my $args = ( @args && ref $args[0] eq 'HASH' ) ? shift @args : {}; + $args = _get_args( $args, qw/locked/ ); + my ($binmode) = @args; $binmode = ( ( caller(0) )[10] || {} )->{ 'open' . substr( $v, -1, 1 ) } unless defined $binmode; - $self->filehandle( $v, $binmode ); + $self->filehandle( $args, $v, $binmode ); + }; + *{ $k . "_raw" } = sub { + my ( $self, @args ) = @_; + my $args = ( @args && ref $args[0] eq 'HASH' ) ? shift @args : {}; + $args = _get_args( $args, qw/locked/ ); + $self->filehandle( $args, $v, ":raw" ); + }; + *{ $k . "_utf8" } = sub { + my ( $self, @args ) = @_; + my $args = ( @args && ref $args[0] eq 'HASH' ) ? shift @args : {}; + $args = _get_args( $args, qw/locked/ ); + $self->filehandle( $args, $v, ":raw:encoding(UTF-8)" ); }; - *{ $k . "_raw" } = sub { $_[0]->filehandle( $v, ":raw" ) }; - *{ $k . "_utf8" } = sub { $_[0]->filehandle( $v, ":raw:encoding(UTF-8)" ) }; } @@ -525,8 +618,11 @@ sub realpath { + my $self = shift; require Cwd; - return path( Cwd::realpath( $_[0]->[PATH] ) ); + my $realpath = eval { Cwd::realpath( $self->[PATH] ) }; + $self->_throw("resolving realpath") unless defined $realpath and length $realpath; + return path($realpath); } @@ -566,9 +662,7 @@ my $args = _get_args( shift, qw/binmode/ ); my $binmode = $args->{binmode}; $binmode = ( ( caller(0) )[10] || {} )->{'open<'} unless defined $binmode; - my $fh = $self->filehandle( "<", $binmode ); - require Fcntl; - flock( $fh, Fcntl::LOCK_SH() ) or $self->_throw('flock (LOCK_SH)'); + my $fh = $self->filehandle( { locked => 1 }, "<", $binmode ); if ( ( defined($binmode) ? $binmode : "" ) eq ":unix" and my $size = -s $fh ) { @@ -601,15 +695,11 @@ my $args = ( @data && ref $data[0] eq 'HASH' ) ? shift @data : {}; $args = _get_args( $args, qw/binmode/ ); my $binmode = $args->{binmode}; + # get default binmode from caller's lexical scope (see "perldoc open") $binmode = ( ( caller(0) )[10] || {} )->{'open>'} unless defined $binmode; my $temp = path( $self->[PATH] . $TID . $$ ); - my $fh = $temp->filehandle( ">", $binmode ); - require Fcntl; - flock( $fh, Fcntl::LOCK_EX() ) or $self->_throw( 'flock (LOCK_EX)', $temp->[PATH] ); - seek( $fh, 0, Fcntl::SEEK_SET() ) or $self->_throw( 'seek', $temp->[PATH] ); - truncate( $fh, 0 ) or $self->_throw( 'truncate', $temp->[PATH] ); + my $fh = $temp->filehandle( { locked => 1 }, ">", $binmode ); print {$fh} map { ref eq 'ARRAY' ? @$_ : $_ } @data; - flock( $fh, Fcntl::LOCK_UN() ) or $self->_throw( 'flock (LOCK_UN)', $temp->[PATH] ); close $fh or $self->_throw( 'close', $temp->[PATH] ); # spewing need to follow the link @@ -699,7 +789,7 @@ =pod -=encoding utf-8 +=encoding UTF-8 =head1 NAME @@ -707,7 +797,7 @@ =head1 VERSION -version 0.038 +version 0.047 =head1 SYNOPSIS @@ -764,7 +854,7 @@ the object gives you back the path (after some clean up). File input/output methods C<flock> handles before reading or writing, -as appropriate. +as appropriate (if supported by the platform). The C<*_utf8> methods (C<slurp_utf8>, C<lines_utf8>, etc.) operate in raw mode without CRLF translation. Installing L<Unicode::UTF8> 0.58 or later @@ -864,14 +954,18 @@ $abs = path("foo/bar")->absolute; $abs = path("foo/bar")->absolute("/tmp"); -Returns a new C<Path::Tiny> object with an absolute path. Unless -an argument is given, the current directory is used as the absolute base path. -The argument must be absolute or you won't get an absolute result. +Returns a new C<Path::Tiny> object with an absolute path (or itself if already +absolute). Unless an argument is given, the current directory is used as the +absolute base path. The argument must be absolute or you won't get an absolute +result. This will not resolve upward directories ("foo/../bar") unless C<canonpath> in L<File::Spec> would normally do so on your platform. If you need them resolved, you must call the more expensive C<realpath> method instead. +On Windows, an absolute path without a volume component will have it added +based on the current drive. + =head2 append, append_raw, append_utf8 path("foo.txt")->append(@data); @@ -965,11 +1059,18 @@ =head2 filehandle $fh = path("/tmp/foo.txt")->filehandle($mode, $binmode); + $fh = path("/tmp/foo.txt")->filehandle({ locked => 1 }, $mode, $binmode); Returns an open file handle. The C<$mode> argument must be a Perl-style read/write mode string ("<" ,">", "<<", etc.). If a C<$binmode> is given, it is set during the C<open> call. +An optional hash reference may be used to pass options. The only option is +C<locked>. If true, handles opened for writing, appending or read-write are +locked with C<LOCK_EX>; otherwise, they are locked with C<LOCK_SH>. When using +C<locked>, ">" or "+>" modes will delay truncation until after the lock is +acquired. + See C<openr>, C<openw>, C<openrw>, and C<opena> for sugar. =head2 is_absolute, is_relative @@ -1093,6 +1194,14 @@ C<open*_raw> and C<open*_utf8> equivalents that use C<:raw> and C<:raw:encoding(UTF-8)>, respectively. +An optional hash reference may be used to pass options. The only option is +C<locked>. If true, handles opened for writing, appending or read-write are +locked with C<LOCK_EX>; otherwise, they are locked for C<LOCK_SH>. + + $fh = path("foo.txt")->openrw_utf8( { locked => 1 } ); + +See L</filehandle> for more on locking. + =head2 parent $parent = path("foo/bar/baz")->parent; # foo/bar @@ -1114,6 +1223,11 @@ parts resolved using L<Cwd>'s C<realpath>. Compared to C<absolute>, this is more expensive as it must actually consult the filesystem. +If the path can't be resolved (e.g. if it includes directories that don't exist), +an exception will be thrown: + + $real = path("doesnt_exist/foo")->realpath; # dies + =head2 relative $rel = path("/tmp/foo/bar")->relative("/tmp"); # foo/bar @@ -1235,7 +1349,7 @@ =for Pod::Coverage openr_utf8 opena_utf8 openw_utf8 openrw_utf8 openr_raw opena_raw openw_raw openrw_raw -DOES +IS_BSD IS_WIN32 =head1 EXCEPTION HANDLING @@ -1267,7 +1381,14 @@ =head1 CAVEATS -=head2 NFS and BSD +=head2 File locking + +If flock is not supported on a platform, it will not be used, even if +locking is requested. + +See additional caveats below. + +=head3 NFS and BSD On BSD, Perl's flock implementation may not work to lock files on an NFS filesystem. Path::Tiny has some heuristics to detect this @@ -1277,6 +1398,12 @@ use warnings FATAL => 'flock'; +=head3 AIX and locking + +AIX requires a write handle for locking. Therefore, calls that normally +open a read handle and take a shared lock instead will open a read-write +handle and take an exclusive lock. + =head2 utf8 vs UTF-8 All the C<*_utf8> methods use C<:encoding(UTF-8)> -- either as @@ -1307,15 +1434,16 @@ =head2 Default IO layers and the open pragma If you have Perl 5.10 or later, file input/output methods (C<slurp>, C<spew>, -etc.) and high-level handle opening methods ( C<openr>, C<openw>, etc. but not -C<filehandle>) respect default encodings set by the C<-C> switch or lexical +etc.) and high-level handle opening methods ( C<filehandle>, C<openr>, +C<openw>, etc. ) respect default encodings set by the C<-C> switch or lexical L<open> settings of the caller. For UTF-8, this is almost certainly slower than using the dedicated C<_utf8> methods if you have L<Unicode::UTF8>. =head1 TYPE CONSTRAINTS AND COERCION A standard L<MooseX::Types> library is available at -L<MooseX::Types::Path::Tiny>. +L<MooseX::Types::Path::Tiny>. A L<Type::Tiny> equivalent is available as +L<Types::Path::Tiny>. =head1 SEE ALSO @@ -1405,6 +1533,10 @@ =item * +Geraud Continsouzas <[email protected]> + +=item * + Goro Fuji <[email protected]> =item * @@ -1427,6 +1559,10 @@ Toby Inkster <[email protected]> +=item * + +김도형 - Keedi Kim <[email protected]> + =back =head1 COPYRIGHT AND LICENSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/t/00-compile.t new/Path-Tiny-0.047/t/00-compile.t --- old/Path-Tiny-0.038/t/00-compile.t 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/t/00-compile.t 1970-01-01 01:00:00.000000000 +0100 @@ -1,49 +0,0 @@ -use strict; -use warnings; - -# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.033 - -use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); - - - -my @module_files = ( - 'Path/Tiny.pm' -); - - - -# fake home for cpan-testers -use File::Temp; -local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); - - -use File::Spec; -use IPC::Open3; -use IO::Handle; - -my @warnings; -for my $lib (@module_files) -{ - # see L<perlfaq8/How can I capture STDERR from an external command?> - open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; - my $stderr = IO::Handle->new; - - my $pid = open3($stdin, '>&STDERR', $stderr, $^X, '-Mblib', '-e', "require q[$lib]"); - binmode $stderr, ':crlf' if $^O eq 'MSWin32'; - my @_warnings = <$stderr>; - waitpid($pid, 0); - is($? >> 8, 0, "$lib loaded ok"); - - if (@_warnings) - { - warn @_warnings; - push @warnings, @_warnings; - } -} - - - -is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/t/00-report-prereqs.t new/Path-Tiny-0.047/t/00-report-prereqs.t --- old/Path-Tiny-0.038/t/00-report-prereqs.t 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/t/00-report-prereqs.t 2013-11-26 21:11:22.000000000 +0100 @@ -3,6 +3,8 @@ use strict; use warnings; +# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.010 + use Test::More tests => 1; use ExtUtils::MakeMaker; @@ -10,6 +12,8 @@ use List::Util qw/max/; my @modules = qw( + CPAN::Meta + CPAN::Meta::Requirements Carp Cwd Digest @@ -25,8 +29,6 @@ File::Spec::Unix File::Temp File::stat - IO::Handle - IPC::Open3 List::Util Test::FailWarnings Test::More @@ -41,20 +43,46 @@ warnings ); +my %exclude = map {; $_ => 1 } qw( + +); + +my ($source) = grep { -f $_ } qw/MYMETA.json MYMETA.yml META.json/; +$source = "META.yml" unless defined $source; + # replace modules with dynamic results from MYMETA.json if we can # (hide CPAN::Meta from prereq scanner) my $cpan_meta = "CPAN::Meta"; -if ( -f "MYMETA.json" && eval "require $cpan_meta" ) { ## no critic - if ( my $meta = eval { CPAN::Meta->load_file("MYMETA.json") } ) { +my $cpan_meta_req = "CPAN::Meta::Requirements"; +my $all_requires; +if ( -f $source && eval "require $cpan_meta" ) { ## no critic + if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { + + # Get ALL modules mentioned in META (any phase/type) my $prereqs = $meta->prereqs; - delete $prereqs->{develop}; + delete $prereqs->{develop} if not $ENV{AUTHOR_TESTING}; my %uniq = map {$_ => 1} map { keys %$_ } map { values %$_ } values %$prereqs; $uniq{$_} = 1 for @modules; # don't lose any static ones - @modules = sort keys %uniq; + @modules = sort grep { ! $exclude{$_} } keys %uniq; + + # If verifying, merge 'requires' only for major phases + if ( 1 ) { + $prereqs = $meta->effective_prereqs; # get the object, not the hash + if (eval "require $cpan_meta_req; 1") { ## no critic + $all_requires = $cpan_meta_req->new; + for my $phase ( qw/configure build test runtime/ ) { + $all_requires->add_requirements( + $prereqs->requirements_for($phase, 'requires') + ); + } + } + } } } my @reports = [qw/Version Module/]; +my @dep_errors; +my $req_hash = defined($all_requires) ? $all_requires->as_string_hash : {}; for my $mod ( @modules ) { next if $mod eq 'perl'; @@ -66,9 +94,29 @@ my $ver = MM->parse_version( catfile($prefix, $file) ); $ver = "undef" unless defined $ver; # Newer MM should do this anyway push @reports, [$ver, $mod]; + + if ( 1 && $all_requires ) { + my $req = $req_hash->{$mod}; + if ( defined $req && length $req ) { + if ( ! defined eval { version->parse($ver) } ) { + push @dep_errors, "$mod version '$ver' cannot be parsed (version '$req' required)"; + } + elsif ( ! $all_requires->accepts_module( $mod => $ver ) ) { + push @dep_errors, "$mod version '$ver' is not in required range '$req'"; + } + } + } + } else { push @reports, ["missing", $mod]; + + if ( 1 && $all_requires ) { + my $req = $req_hash->{$mod}; + if ( defined $req && length $req ) { + push @dep_errors, "$mod is not installed (version '$req' required)"; + } + } } } @@ -76,7 +124,17 @@ my $vl = max map { length $_->[0] } @reports; my $ml = max map { length $_->[1] } @reports; splice @reports, 1, 0, ["-" x $vl, "-" x $ml]; - diag "Prerequisite Report:\n", map {sprintf(" %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @reports; + diag "\nVersions for all modules listed in $source (including optional ones):\n", + map {sprintf(" %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @reports; +} + +if ( @dep_errors ) { + diag join("\n", + "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", + "The following REQUIRED prerequisites were not satisfied:\n", + @dep_errors, + "\n" + ); } pass; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/t/filesystem.t new/Path-Tiny-0.047/t/filesystem.t --- old/Path-Tiny-0.038/t/filesystem.t 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/t/filesystem.t 2013-11-26 21:11:22.000000000 +0100 @@ -229,6 +229,14 @@ my $abs_t = path("t")->absolute; my $case = $abs_t->child("../lib"); is( $case->realpath, $lib->realpath, "realpath on absolute" ); + + # non-existent realpath should throw error + eval { path("lkajdfak/djslakdj")->realpath }; + like( + $@, + qr/Error resolving realpath/, + "caught error from realpath on non-existent file" + ); } { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/t/locking.t new/Path-Tiny-0.047/t/locking.t --- old/Path-Tiny-0.038/t/locking.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Path-Tiny-0.047/t/locking.t 2013-11-26 21:11:22.000000000 +0100 @@ -0,0 +1,45 @@ +use 5.008001; +use strict; +use warnings; +use Test::More 0.96; +use File::Spec; +use Cwd; + +use lib 't/lib'; +use TestUtils qw/exception/; + +use Fcntl ':flock'; +use Path::Tiny; + +my $IS_BSD = $^O =~ /bsd$/; + +if ($IS_BSD) { + # is temp partition lockable? + my $file = Path::Tiny->tempfile; + open my $fh, ">>", $file; + flock $fh, LOCK_EX + or plan skip_all => "Can't lock tempfiles on this OS/filesystem"; +} + +subtest 'write locks blocks read lock' => sub { + my $file = Path::Tiny->tempfile; + ok $file, "Got a tempfile"; + my $fh = $file->openw( { locked => 1 } ); + ok $fh, "Opened file for writing with lock"; + $fh->autoflush(1); + print {$fh} "hello"; + # check if a different process can get a lock; use RW mode for AIX + my $locktester = Path::Tiny->tempfile; + $locktester->spew(<<"HERE"); +use strict; +use warnings; +use Fcntl ':flock'; +open my \$fh, "+<", "$file"; +exit flock( \$fh, LOCK_SH|LOCK_NB ); +HERE + my $rc = system( $^X, $locktester ); + isnt( $rc, -1, "ran process to try to get lock" ); + is( $rc >> 8, 0, "process failed to get lock" ); +}; + +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/t/zzz-spec.t new/Path-Tiny-0.047/t/zzz-spec.t --- old/Path-Tiny-0.038/t/zzz-spec.t 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/t/zzz-spec.t 2013-11-26 21:11:22.000000000 +0100 @@ -58,11 +58,12 @@ [ "path('t4')->absolute('/t1/t2/t3')", '/t1/t2/t3/t4' ], [ "path('t4/t5')->absolute('/t1/t2/t3')", '/t1/t2/t3/t4/t5' ], [ "path('.')->absolute('/t1/t2/t3')", '/t1/t2/t3' ], - [ "path('/t1')->absolute('/t1/t2/t3')", '/t1' ], [ "path('///../../..//./././a//b/.././c/././')", '/a/b/../c', '/a/c' ], [ "path('a/../../b/c')", 'a/../../b/c', '../b/c' ], [ "path('..')->absolute('/t1/t2/t3')", '/t1/t2/t3/..', '/t1/t2' ], [ "path('../t4')->absolute('/t1/t2/t3')", '/t1/t2/t3/../t4', '/t1/t2/t4' ], + # need to wash through rootdir->absolute->child to pick up volume on Windows + [ "path('/t1')->absolute('/t1/t2/t3')", Path::Tiny->rootdir->absolute->child("t1") ], ); my @win32_tests; @@ -96,7 +97,7 @@ [ "path('a/..','../b')", '../b' ], [ "path('A:', 'foo')", 'A:/foo' ], [ "path('a:/')", 'A:/' ], - [ "path('A:f')", 'A:f' ], + [ "path('A:f')", 'A:/f' ], [ "path('A:/')", 'A:/' ], [ "path('a\\..\\..\\b\\c')", '../b/c' ], [ "path('//a\\b//c')", '//a/b/c' ], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/xt/author/00-compile.t new/Path-Tiny-0.047/xt/author/00-compile.t --- old/Path-Tiny-0.038/xt/author/00-compile.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Path-Tiny-0.047/xt/author/00-compile.t 2013-11-26 21:11:22.000000000 +0100 @@ -0,0 +1,51 @@ +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.037 + +use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); + + + +my @module_files = ( + 'Path/Tiny.pm' +); + + + +# fake home for cpan-testers +use File::Temp; +local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); + + +my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; + +use File::Spec; +use IPC::Open3; +use IO::Handle; + +my @warnings; +for my $lib (@module_files) +{ + # see L<perlfaq8/How can I capture STDERR from an external command?> + open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; + my $stderr = IO::Handle->new; + + my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); + binmode $stderr, ':crlf' if $^O eq 'MSWin32'; + my @_warnings = <$stderr>; + waitpid($pid, 0); + is($?, 0, "$lib loaded ok"); + + if (@_warnings) + { + warn @_warnings; + push @warnings, @_warnings; + } +} + + + +is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.038/xt/author/pod-spell.t new/Path-Tiny-0.047/xt/author/pod-spell.t --- old/Path-Tiny-0.038/xt/author/pod-spell.t 2013-10-02 00:20:18.000000000 +0200 +++ new/Path-Tiny-0.047/xt/author/pod-spell.t 2013-11-26 21:11:22.000000000 +0100 @@ -10,6 +10,7 @@ add_stopwords(<DATA>); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ +AIX BENCHMARKING CRLF SHA @@ -49,6 +50,9 @@ George Hartzell hartzell +Geraud +Continsouzas +geraud Goro Fuji gfuji @@ -67,6 +71,7 @@ Toby Inkster tobyink +김도형 lib Path Tiny -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
