Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package perl-Path-Tiny for openSUSE:Factory checked in at 2022-01-22 08:17:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Path-Tiny (Old) and /work/SRC/openSUSE:Factory/.perl-Path-Tiny.new.1938 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Path-Tiny" Sat Jan 22 08:17:57 2022 rev:28 rq:947649 version:0.122 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Path-Tiny/perl-Path-Tiny.changes 2021-10-29 22:34:48.455695137 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Path-Tiny.new.1938/perl-Path-Tiny.changes 2022-01-22 08:18:13.242888977 +0100 @@ -1,0 +2,13 @@ +Mon Jan 17 03:07:25 UTC 2022 - Tina M??ller <timueller+p...@suse.de> + +- updated to 0.122 + see /usr/share/doc/packages/perl-Path-Tiny/Changes + + 0.122 2022-01-16 10:05:08-05:00 America/New_York + - No changes from 0.121-TRIAL. + 0.121 2022-01-08 11:05:33-05:00 America/New_York (TRIAL RELEASE) + [Additions] + - Adds `size` and `size_human` methods. The latter gives `ls -lh` style + output, with options to choose base2 or base10 forms. + +------------------------------------------------------------------- Old: ---- Path-Tiny-0.120.tar.gz New: ---- Path-Tiny-0.122.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Path-Tiny.spec ++++++ --- /var/tmp/diff_new_pack.dQSFtC/_old 2022-01-22 08:18:13.742885608 +0100 +++ /var/tmp/diff_new_pack.dQSFtC/_new 2022-01-22 08:18:13.746885582 +0100 @@ -1,7 +1,7 @@ # # spec file for package perl-Path-Tiny # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %define cpan_name Path-Tiny Name: perl-Path-Tiny -Version: 0.120 +Version: 0.122 Release: 0 Summary: File path utility License: Apache-2.0 ++++++ Path-Tiny-0.120.tar.gz -> Path-Tiny-0.122.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/Changes new/Path-Tiny-0.122/Changes --- old/Path-Tiny-0.120/Changes 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/Changes 2022-01-16 16:05:25.000000000 +0100 @@ -1,5 +1,16 @@ Revision history for Path-Tiny +0.122 2022-01-16 10:05:08-05:00 America/New_York + + - No changes from 0.121-TRIAL. + +0.121 2022-01-08 11:05:33-05:00 America/New_York (TRIAL RELEASE) + + [Additions] + + - Adds `size` and `size_human` methods. The latter gives `ls -lh` style + output, with options to choose base2 or base10 forms. + 0.120 2021-10-24 12:12:57-04:00 America/New_York - No changes from 0.119-TRIAL. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/MANIFEST new/Path-Tiny-0.122/MANIFEST --- old/Path-Tiny-0.120/MANIFEST 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/MANIFEST 2022-01-16 16:05:25.000000000 +0100 @@ -38,6 +38,7 @@ t/recurse.t t/rel-abs.t t/sig_die.t +t/size.t t/subsumes.t t/symlinks.t t/temp.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/META.json new/Path-Tiny-0.122/META.json --- old/Path-Tiny-0.120/META.json 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/META.json 2022-01-16 16:05:25.000000000 +0100 @@ -112,11 +112,11 @@ "provides" : { "Path::Tiny" : { "file" : "lib/Path/Tiny.pm", - "version" : "0.120" + "version" : "0.122" }, "Path::Tiny::Error" : { "file" : "lib/Path/Tiny.pm", - "version" : "0.120" + "version" : "0.122" } }, "release_status" : "stable", @@ -131,7 +131,7 @@ "web" : "https://github.com/dagolden/Path-Tiny" } }, - "version" : "0.120", + "version" : "0.122", "x_authority" : "cpan:DAGOLDEN", "x_contributors" : [ "Alex Efros <power...@powerman.name>", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/META.yml new/Path-Tiny-0.122/META.yml --- old/Path-Tiny-0.120/META.yml 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/META.yml 2022-01-16 16:05:25.000000000 +0100 @@ -36,10 +36,10 @@ provides: Path::Tiny: file: lib/Path/Tiny.pm - version: '0.120' + version: '0.122' Path::Tiny::Error: file: lib/Path/Tiny.pm - version: '0.120' + version: '0.122' recommends: Unicode::UTF8: '0.58' requires: @@ -66,7 +66,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.120' +version: '0.122' x_authority: cpan:DAGOLDEN x_contributors: - 'Alex Efros <power...@powerman.name>' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/Makefile.PL new/Path-Tiny-0.122/Makefile.PL --- old/Path-Tiny-0.120/Makefile.PL 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/Makefile.PL 2022-01-16 16:05:25.000000000 +0100 @@ -48,7 +48,7 @@ "lib" => 0, "open" => 0 }, - "VERSION" => "0.120", + "VERSION" => "0.122", "test" => { "TESTS" => "t/*.t" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/README new/Path-Tiny-0.122/README --- old/Path-Tiny-0.120/README 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/README 2022-01-16 16:05:25.000000000 +0100 @@ -2,7 +2,7 @@ Path::Tiny - File path utility VERSION - version 0.120 + version 0.122 SYNOPSIS use Path::Tiny; @@ -748,6 +748,32 @@ Current API available since 0.058. + size, size_human + my $p = path("foo"); # with size 1025 bytes + + $p->size; # "1025" + $p->size_human; # "1.1 K" + $p->size_human( {format => "iec"} ); # "1.1 KiB" + + Returns the size of a file. The "size" method is just a wrapper around + "-s". + + The "size_human" method provides a human-readable string similar to "ls + -lh". Like "ls", it rounds upwards and provides one decimal place for + single-digit sizes and no decimal places for larger sizes. The only + available option is "format", which has three valid values: + + * 'ls' (the default): base-2 sizes, with "ls" style single-letter + suffixes (K, M, etc.) + + * 'iec': base-2 sizes, with IEC binary suffixes (KiB, MiB, etc.) + + * 'si': base-10 sizes, with SI decimal suffixes (kB, MB, etc.) + + If "-s" would return "undef", "size_human" returns the empty string. + + Current API available since 0.122. + slurp, slurp_raw, slurp_utf8 $data = path("foo.txt")->slurp; $data = path("foo.txt")->slurp( {binmode => ":raw"} ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/dist.ini new/Path-Tiny-0.122/dist.ini --- old/Path-Tiny-0.120/dist.ini 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/dist.ini 2022-01-16 16:05:25.000000000 +0100 @@ -10,7 +10,10 @@ stopwords = AIX stopwords = BENCHMARKING stopwords = CRLF +stopwords = IEC +stopwords = KiB stopwords = Lustre +stopwords = MiB stopwords = NFS stopwords = SHA stopwords = UNC @@ -19,6 +22,8 @@ stopwords = cwd stopwords = dirname stopwords = fatalize +stopwords = iec +stopwords = kB stopwords = lstat stopwords = mkpath stopwords = opena @@ -27,6 +32,7 @@ stopwords = openw stopwords = perms stopwords = realpath +stopwords = si stopwords = stat stopwords = stringifying stopwords = subclasses diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/lib/Path/Tiny.pm new/Path-Tiny-0.122/lib/Path/Tiny.pm --- old/Path-Tiny-0.120/lib/Path/Tiny.pm 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/lib/Path/Tiny.pm 2022-01-16 16:05:25.000000000 +0100 @@ -5,7 +5,7 @@ package Path::Tiny; # ABSTRACT: File path utility -our $VERSION = '0.120'; +our $VERSION = '0.122'; # Dependencies use Config; @@ -1772,6 +1772,75 @@ return path( $self->parent->[PATH], @_ ); } +#pod =method size, size_human +#pod +#pod my $p = path("foo"); # with size 1025 bytes +#pod +#pod $p->size; # "1025" +#pod $p->size_human; # "1.1 K" +#pod $p->size_human( {format => "iec"} ); # "1.1 KiB" +#pod +#pod Returns the size of a file. The C<size> method is just a wrapper around C<-s>. +#pod +#pod The C<size_human> method provides a human-readable string similar to +#pod C<ls -lh>. Like C<ls>, it rounds upwards and provides one decimal place for +#pod single-digit sizes and no decimal places for larger sizes. The only available +#pod option is C<format>, which has three valid values: +#pod +#pod =for :list +#pod * 'ls' (the default): base-2 sizes, with C<ls> style single-letter suffixes (K, M, etc.) +#pod * 'iec': base-2 sizes, with IEC binary suffixes (KiB, MiB, etc.) +#pod * 'si': base-10 sizes, with SI decimal suffixes (kB, MB, etc.) +#pod +#pod If C<-s> would return C<undef>, C<size_human> returns the empty string. +#pod +#pod Current API available since 0.122. +#pod +#pod =cut + +sub size { -s $_[0]->[PATH] } + +my %formats = ( + 'ls' => [ 1024, log(1024), [ "", map { " $_" } qw/K M G T/ ] ], + 'iec' => [ 1024, log(1024), [ "", map { " $_" } qw/KiB MiB GiB TiB/ ] ], + 'si' => [ 1000, log(1000), [ "", map { " $_" } qw/kB MB GB TB/ ] ], +); + +sub _formats { return $formats{$_[0]} } + +sub size_human { + my $self = shift; + my $args = _get_args( shift, qw/format/ ); + my $format = defined $args->{format} ? $args->{format} : "ls"; + my $fmt_opts = $formats{$format} + or Carp::croak("Invalid format '$format' for size_human()"); + my $size = -s $self->[PATH]; + return defined $size ? _human_size( $size, @$fmt_opts ) : ""; +} + +sub _ceil { + return $_[0] == int($_[0]) ? $_[0] : int($_[0]+1); +} + +sub _human_size { + my ( $size, $base, $log_base, $suffixes ) = @_; + return "0" if $size == 0; + + my $mag = int( log($size) / $log_base ); + $size /= $base**$mag; + $size = + $mag == 0 ? $size + : length( int($size) ) == 1 ? _ceil( $size * 10 ) / 10 + : _ceil($size); + if ( $size >= $base ) { + $size /= $base; + $mag++; + } + + my $fmt = ( $mag == 0 || length( int($size) ) > 1 ) ? "%.0f%s" : "%.1f%s"; + return sprintf( $fmt, $size, $suffixes->[$mag] ); +} + #pod =method slurp, slurp_raw, slurp_utf8 #pod #pod $data = path("foo.txt")->slurp; @@ -2176,7 +2245,7 @@ =head1 VERSION -version 0.120 +version 0.122 =head1 SYNOPSIS @@ -2971,6 +3040,41 @@ Current API available since 0.058. +=head2 size, size_human + + my $p = path("foo"); # with size 1025 bytes + + $p->size; # "1025" + $p->size_human; # "1.1 K" + $p->size_human( {format => "iec"} ); # "1.1 KiB" + +Returns the size of a file. The C<size> method is just a wrapper around C<-s>. + +The C<size_human> method provides a human-readable string similar to +C<ls -lh>. Like C<ls>, it rounds upwards and provides one decimal place for +single-digit sizes and no decimal places for larger sizes. The only available +option is C<format>, which has three valid values: + +=over 4 + +=item * + +'ls' (the default): base-2 sizes, with C<ls> style single-letter suffixes (K, M, etc.) + +=item * + +'iec': base-2 sizes, with IEC binary suffixes (KiB, MiB, etc.) + +=item * + +'si': base-10 sizes, with SI decimal suffixes (kB, MB, etc.) + +=back + +If C<-s> would return C<undef>, C<size_human> returns the empty string. + +Current API available since 0.122. + =head2 slurp, slurp_raw, slurp_utf8 $data = path("foo.txt")->slurp; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/t/size.t new/Path-Tiny-0.122/t/size.t --- old/Path-Tiny-0.120/t/size.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Path-Tiny-0.122/t/size.t 2022-01-16 16:05:25.000000000 +0100 @@ -0,0 +1,152 @@ +use 5.008001; +use strict; +use warnings; +use Test::More 0.96; + +use lib 't/lib'; +use TestUtils qw/exception tempd/; + +use Path::Tiny; + +subtest "size API tests" => sub { + my $wd = tempd(); + my $path = path("1025"); + $path->spew( "A" x 1025 ); + is( $path->size, -s $path, "size() is -s" ); + is( $path->size_human, "1.1 K", "size_human() is 1.1 K" ); +}; + +subtest "size_human format" => sub { + my $wd = tempd(); + my $base2 = path("1024"); + $base2->spew( "A" x 1024 ); + my $base10 = path("1000"); + $base10->spew( "A" x 1000 ); + + is( $base2->size_human, "1.0 K", "default" ); + is( $base2->size_human( { format => "ls" } ), "1.0 K", "explicit ls" ); + is( $base2->size_human( { format => "iec" } ), "1.0 KiB", "iec" ); + is( $base10->size_human( { format => "si" } ), "1.0 kB", "si" ); + + is( path("doesnotexist")->size_human, "", "missing file" ); + + like( + exception { $base2->size_human( { format => "fake" } ) }, + qr/Invalid format 'fake'/, + "bad format exception" + ); + +}; + +# The rest of the tests use the private function for size conversion +# rather than actually creating files of each size. Test cases were +# derived from actual `ls -lh` output on Ubuntu 20.04. + +my $kib = 1024; +my %ls_tests = ( + 0 => "0", + $kib - 1 => "1023", + $kib => "1.0 K", + $kib + 1 => "1.1 K", + int( 1.1 * $kib ) => "1.1 K", + int( 1.1 * $kib ) + 1 => "1.2 K", + int( 1.9 * $kib ) => "1.9 K", + int( 1.9 * $kib ) + 1 => "2.0 K", + 9 * $kib => "9.0 K", + 9 * $kib + 1 => "9.1 K", + int( 9.9 * $kib ) => "9.9 K", + int( 9.9 * $kib ) + 1 => "10 K", + 10 * $kib => "10 K", + 10 * $kib + 1 => "11 K", + ( $kib - 1 ) * $kib => "1023 K", + ( $kib - 1 ) * $kib + 1 => "1.0 M", + + $kib**2 - 1 => "1.0 M", + $kib**2 => "1.0 M", + $kib**2 + 1 => "1.1 M", + int( 1.1 * $kib**2 ) => "1.1 M", + int( 1.1 * $kib**2 ) + 1 => "1.2 M", + int( 1.9 * $kib**2 ) => "1.9 M", + int( 1.9 * $kib**2 ) + 1 => "2.0 M", + 9 * $kib**2 => "9.0 M", + 9 * $kib**2 + 1 => "9.1 M", + int( 9.9 * $kib**2 ) => "9.9 M", + int( 9.9 * $kib**2 ) + 1 => "10 M", + 10 * $kib**2 => "10 M", + 10 * $kib**2 + 1 => "11 M", + ( $kib - 1 ) * $kib**2 => "1023 M", + ( $kib - 1 ) * $kib**2 + 1 => "1.0 G", +); + +subtest "ls format" => sub { + for my $k ( sort { $a <=> $b } keys %ls_tests ) { + my $opts = Path::Tiny::_formats("ls"); + my $got = Path::Tiny::_human_size( $k, @$opts ); + is( $got, $ls_tests{$k}, "ls: $k" ); + } +}; + +subtest "iec format" => sub { + for my $k ( sort { $a <=> $b } keys %ls_tests ) { + my $opts = Path::Tiny::_formats("iec"); + my $got = Path::Tiny::_human_size( $k, @$opts ); + my $want = $ls_tests{$k}; + $want .= "iB" if $want =~ /[a-z]/i; + is( $got, $want, "iec: $k" ); + } +}; + +my $kb = 1000; +my %si_tests = ( + 0 => "0", + $kb - 1 => "999", + $kb => "1.0 kB", + $kb + 1 => "1.1 kB", + int( 1.1 * $kb ) => "1.1 kB", + int( 1.1 * $kb ) + 1 => "1.2 kB", + int( 1.9 * $kb ) => "1.9 kB", + int( 1.9 * $kb ) + 1 => "2.0 kB", + 9 * $kb => "9.0 kB", + 9 * $kb + 1 => "9.1 kB", + int( 9.9 * $kb ) => "9.9 kB", + int( 9.9 * $kb ) + 1 => "10 kB", + 10 * $kb => "10 kB", + 10 * $kb + 1 => "11 kB", + ( $kb - 1 ) * $kb => "999 kB", + ( $kb - 1 ) * $kb + 1 => "1.0 MB", + + $kb**2 - 1 => "1.0 MB", + $kb**2 => "1.0 MB", + $kb**2 + 1 => "1.1 MB", + int( 1.1 * $kb**2 ) => "1.1 MB", + int( 1.1 * $kb**2 ) + 1 => "1.2 MB", + int( 1.9 * $kb**2 ) => "1.9 MB", + int( 1.9 * $kb**2 ) + 1 => "2.0 MB", + 9 * $kb**2 => "9.0 MB", + 9 * $kb**2 + 1 => "9.1 MB", + int( 9.9 * $kb**2 ) => "9.9 MB", + int( 9.9 * $kb**2 ) + 1 => "10 MB", + 10 * $kb**2 => "10 MB", + 10 * $kb**2 + 1 => "11 MB", + ( $kb - 1 ) * $kb**2 => "999 MB", + ( $kb - 1 ) * $kb**2 + 1 => "1.0 GB", +); + +subtest "si format" => sub { + for my $k ( sort { $a <=> $b } keys %si_tests ) { + my $opts = Path::Tiny::_formats("si"); + my $got = Path::Tiny::_human_size( $k, @$opts ); + is( $got, $si_tests{$k}, "si: $k" ); + } +}; + +done_testing; +# +# This file is part of Path-Tiny +# +# This software is Copyright (c) 2014 by David Golden. +# +# This is free software, licensed under: +# +# The Apache License, Version 2.0, January 2004 +# diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Path-Tiny-0.120/xt/author/pod-spell.t new/Path-Tiny-0.122/xt/author/pod-spell.t --- old/Path-Tiny-0.120/xt/author/pod-spell.t 2021-10-24 18:13:13.000000000 +0200 +++ new/Path-Tiny-0.122/xt/author/pod-spell.t 2022-01-16 16:05:25.000000000 +0100 @@ -43,6 +43,7 @@ Gregoire Hartzell Hunt +IEC III Ian Inkster @@ -52,12 +53,14 @@ Karen Karr Keedi +KiB Kim Kjeldsen Knop Lustre Mark Martin +MiB Michael Miyagawa NFS @@ -104,7 +107,9 @@ haarg hartzell ian +iec james +kB keedi lib lstat @@ -127,6 +132,7 @@ regina rivy shlomif +si stat stringifying subclasses