Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package perl-DateTime-Format-Natural for 
openSUSE:Factory checked in at 2021-03-24 16:13:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-DateTime-Format-Natural (Old)
 and      /work/SRC/openSUSE:Factory/.perl-DateTime-Format-Natural.new.2401 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-DateTime-Format-Natural"

Wed Mar 24 16:13:08 2021 rev:6 rq:880561 version:1.12

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/perl-DateTime-Format-Natural/perl-DateTime-Format-Natural.changes
        2020-09-25 16:36:27.236152356 +0200
+++ 
/work/SRC/openSUSE:Factory/.perl-DateTime-Format-Natural.new.2401/perl-DateTime-Format-Natural.changes
      2021-03-24 16:13:09.667952148 +0100
@@ -1,0 +2,17 @@
+Sat Mar 20 03:07:02 UTC 2021 - Tina M??ller <[email protected]>
+
+- updated to 1.12
+   see /usr/share/doc/packages/perl-DateTime-Format-Natural/Changes
+
+  1.12  2021-03-19  <[email protected]>
+   - Merged development version to stable.
+  1.11_03  2021-03-13  <[email protected]>
+   - Refactor extracting duration.
+   - Don't try to trim the extract string twice.
+   - Amend documentation of ::Utils.
+  1.11_02  2020-10-16  <[email protected]>
+   - Introduce utility function trim().
+  1.11_01  2020-10-03  <[email protected]>
+   - Assert that error() returns '' on success.
+
+-------------------------------------------------------------------

Old:
----
  DateTime-Format-Natural-1.11.tar.gz

New:
----
  DateTime-Format-Natural-1.12.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-DateTime-Format-Natural.spec ++++++
--- /var/tmp/diff_new_pack.sY6W4i/_old  2021-03-24 16:13:10.135952638 +0100
+++ /var/tmp/diff_new_pack.sY6W4i/_new  2021-03-24 16:13:10.135952638 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-DateTime-Format-Natural
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -16,18 +16,16 @@
 #
 
 
+%define cpan_name DateTime-Format-Natural
 Name:           perl-DateTime-Format-Natural
-Version:        1.11
+Version:        1.12
 Release:        0
-%define cpan_name DateTime-Format-Natural
 Summary:        Parse informal natural language date/time strings
 License:        Artistic-1.0 OR GPL-1.0-or-later
-Group:          Development/Libraries/Perl
 URL:            https://metacpan.org/release/%{cpan_name}
 Source0:        
https://cpan.metacpan.org/authors/id/S/SC/SCHUBIGER/%{cpan_name}-%{version}.tar.gz
 Source1:        cpanspec.yml
 BuildArch:      noarch
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  perl
 BuildRequires:  perl-macros
 BuildRequires:  perl(Clone)
@@ -54,7 +52,7 @@
 ordinary strings.
 
 %prep
-%setup -q -n %{cpan_name}-%{version}
+%autosetup  -n %{cpan_name}-%{version}
 find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path 
"*/script/*" ! -name "configure" -print0 | xargs -0 chmod 644
 
 %build
@@ -69,7 +67,6 @@
 %perl_gen_filelist
 
 %files -f %{name}.files
-%defattr(-,root,root,755)
 %doc Changes README
 
 %changelog

++++++ DateTime-Format-Natural-1.11.tar.gz -> 
DateTime-Format-Natural-1.12.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/DateTime-Format-Natural-1.11/Changes 
new/DateTime-Format-Natural-1.12/Changes
--- old/DateTime-Format-Natural-1.11/Changes    2020-09-23 21:29:34.000000000 
+0200
+++ new/DateTime-Format-Natural-1.12/Changes    2021-03-19 21:14:02.000000000 
+0100
@@ -1,5 +1,25 @@
 Revision history for Perl extension DateTime::Format::Natural.
 
+1.12  2021-03-19  <[email protected]>
+
+ - Merged development version to stable.
+
+1.11_03  2021-03-13  <[email protected]>
+
+ - Refactor extracting duration.
+
+ - Don't try to trim the extract string twice.
+
+ - Amend documentation of ::Utils.
+
+1.11_02  2020-10-16  <[email protected]>
+
+ - Introduce utility function trim().
+
+1.11_01  2020-10-03  <[email protected]>
+
+ - Assert that error() returns '' on success.
+
 1.11  2020-09-23  <[email protected]>
 
  - Merged development version to stable.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/DateTime-Format-Natural-1.11/META.json 
new/DateTime-Format-Natural-1.12/META.json
--- old/DateTime-Format-Natural-1.11/META.json  2020-09-23 21:29:34.000000000 
+0200
+++ new/DateTime-Format-Natural-1.12/META.json  2021-03-19 21:14:02.000000000 
+0100
@@ -53,7 +53,7 @@
    "provides" : {
       "DateTime::Format::Natural" : {
          "file" : "lib/DateTime/Format/Natural.pm",
-         "version" : "1.11"
+         "version" : "1.12"
       },
       "DateTime::Format::Natural::Calc" : {
          "file" : "lib/DateTime/Format/Natural/Calc.pm",
@@ -69,7 +69,7 @@
       },
       "DateTime::Format::Natural::Duration::Checks" : {
          "file" : "lib/DateTime/Format/Natural/Duration/Checks.pm",
-         "version" : "0.04"
+         "version" : "0.05"
       },
       "DateTime::Format::Natural::Expand" : {
          "file" : "lib/DateTime/Format/Natural/Expand.pm",
@@ -77,7 +77,7 @@
       },
       "DateTime::Format::Natural::Extract" : {
          "file" : "lib/DateTime/Format/Natural/Extract.pm",
-         "version" : "0.11"
+         "version" : "0.13"
       },
       "DateTime::Format::Natural::Formatted" : {
          "file" : "lib/DateTime/Format/Natural/Formatted.pm",
@@ -105,7 +105,7 @@
       },
       "DateTime::Format::Natural::Utils" : {
          "file" : "lib/DateTime/Format/Natural/Utils.pm",
-         "version" : "0.05"
+         "version" : "0.07"
       },
       "DateTime::Format::Natural::Wrappers" : {
          "file" : "lib/DateTime/Format/Natural/Wrappers.pm",
@@ -121,6 +121,6 @@
          "url" : "https://github.com/stsc/DateTime-Format-Natural";
       }
    },
-   "version" : "1.11",
+   "version" : "1.12",
    "x_serialization_backend" : "JSON::PP version 2.97001"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/DateTime-Format-Natural-1.11/META.yml 
new/DateTime-Format-Natural-1.12/META.yml
--- old/DateTime-Format-Natural-1.11/META.yml   2020-09-23 21:29:34.000000000 
+0200
+++ new/DateTime-Format-Natural-1.12/META.yml   2021-03-19 21:14:02.000000000 
+0100
@@ -22,7 +22,7 @@
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: '1.11'
+    version: '1.12'
   DateTime::Format::Natural::Calc:
     file: lib/DateTime/Format/Natural/Calc.pm
     version: '1.44'
@@ -34,13 +34,13 @@
     version: '0.06'
   DateTime::Format::Natural::Duration::Checks:
     file: lib/DateTime/Format/Natural/Duration/Checks.pm
-    version: '0.04'
+    version: '0.05'
   DateTime::Format::Natural::Expand:
     file: lib/DateTime/Format/Natural/Expand.pm
     version: '0.03'
   DateTime::Format::Natural::Extract:
     file: lib/DateTime/Format/Natural/Extract.pm
-    version: '0.11'
+    version: '0.13'
   DateTime::Format::Natural::Formatted:
     file: lib/DateTime/Format/Natural/Formatted.pm
     version: '0.10'
@@ -61,7 +61,7 @@
     version: '0.10'
   DateTime::Format::Natural::Utils:
     file: lib/DateTime/Format/Natural/Utils.pm
-    version: '0.05'
+    version: '0.07'
   DateTime::Format::Natural::Wrappers:
     file: lib/DateTime/Format/Natural/Wrappers.pm
     version: '0.03'
@@ -83,5 +83,5 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: https://github.com/stsc/DateTime-Format-Natural
-version: '1.11'
+version: '1.12'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural/Duration/Checks.pm 
new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural/Duration/Checks.pm
--- 
old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural/Duration/Checks.pm 
    2020-09-23 21:29:34.000000000 +0200
+++ 
new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural/Duration/Checks.pm 
    2021-03-19 21:14:02.000000000 +0100
@@ -4,7 +4,7 @@
 use warnings;
 use boolean qw(true false);
 
-our $VERSION = '0.04';
+our $VERSION = '0.05';
 
 sub for
 {
@@ -85,10 +85,13 @@
 
 sub _first_to_last_extract
 {
-    my ($self, $duration, $date_strings, $indexes, $tokens, $chunks) = @_;
+    my $self = shift;
+    my ($date_strings, $indexes, $tokens, $chunks) = @_;
 
     return false unless @$date_strings == 2;
 
+    my $duration = $self->{data}->{duration};
+
     my %regexes = %{$duration->{first_to_last}{regexes}};
 
     $regexes{first} = $anchor_regex{left}->($regexes{first});
@@ -242,10 +245,13 @@
 
 sub _from_count_to_count_extract
 {
-    my ($self, $duration, $date_strings, $indexes, $tokens, $chunks) = @_;
+    my $self = shift;
+    my ($date_strings, $indexes, $tokens, $chunks) = @_;
 
     return false unless @$date_strings == 2;
 
+    my $duration = $self->{data}->{duration};
+
     my ($entry, $target);
     return false unless $duration_matches->($duration, $date_strings, \$entry, 
\$target);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural/Extract.pm 
new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural/Extract.pm
--- old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural/Extract.pm     
2020-09-23 21:29:34.000000000 +0200
+++ new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural/Extract.pm     
2021-03-19 21:14:02.000000000 +0100
@@ -12,7 +12,9 @@
 use constant GRAMMAR_TYPE  => 0x02;
 use constant DURATION_TYPE => 0x04;
 
-our $VERSION = '0.11';
+use DateTime::Format::Natural::Utils qw(trim);
+
+our $VERSION = '0.13';
 
 my %grammar_durations = map { $_ => true } qw(for_count_unit);
 
@@ -37,8 +39,8 @@
     my $self = shift;
     my ($extract_string) = @_;
 
-    $extract_string =~ s/^\s*[,;.]?//;
-    $extract_string =~ s/[,;.]?\s*$//;
+    $extract_string =~ s/^[,;.]//;
+    $extract_string =~ s/[,;.]$//;
 
     while ($extract_string =~ /([,;.])/g) {
         my $mark = $1;
@@ -51,6 +53,11 @@
         $extract_string =~ s/\Q$mark\E \s+? $pattern/ [token] /x; # pretend 
punctuation marks are tokens
     }
 
+    my $timespan_sep = $self->{data}->__timespan('literal');
+
+    1 while $extract_string =~ s/^$timespan_sep\s+//i;
+    1 while $extract_string =~ s/\s+$timespan_sep$//i;
+
     $self->_rewrite(\$extract_string);
 
     my @tokens = split /\s+/, $extract_string;
@@ -58,52 +65,8 @@
 
     my (@expressions, %skip);
 
-    my $timespan_sep = $self->{data}->__timespan('literal');
-
     if ($extract_string =~ /\s+ $timespan_sep \s+/ix) {
-        my $trim = sub { local $_ = shift; s/^\s+//; s/\s+$//; $_ };
-
-        my @strings = grep /\S/, map $trim->($_), split /\b$timespan_sep\b/i, 
do {
-            local $_ = $extract_string;
-            1 while s/^$timespan_sep\s+//i;
-            1 while s/\s+$timespan_sep$//i;
-            $_
-        };
-        if (@strings) {
-            my $index = 0;
-            $index++ while $extract_string =~ /\G$timespan_sep\s+/gi;
-            my @indexes;
-            for (my $i = 0; $i < @strings; $i++) {
-                my @string_tokens = split /\s+/, $strings[$i];
-                push @indexes, [ $index, $index + $#string_tokens ];
-                $index += $#string_tokens + 1;
-                $index++ while defined $tokens[$index] && $tokens[$index] =~ 
/^$timespan_sep$/i;
-            }
-
-            my $duration = $self->{data}->{duration};
-
-            DURATION: {
-                for (my $i = 0; $i < @strings - 1; $i++) {
-                    next unless $extract_duration->(\%skip, \@indexes, $i);
-                    my $save_expression = false;
-                    my @chunks;
-                    foreach my $extract (qw(_first_to_last_extract 
_from_count_to_count_extract)) {
-                        if ($self->$extract($duration, $get_range->(\@strings, 
$i), $get_range->(\@indexes, $i), \@tokens, \@chunks)) {
-                            $save_expression = true;
-                            last;
-                        }
-                    }
-                    if ($save_expression) {
-                        my $timespan_sep_index = $chunks[0]->[0][1] + 1;
-                        my $expression = join ' ', ($chunks[0]->[1], 
$tokens[$timespan_sep_index], $chunks[1]->[1]);
-                        my @indexes = ($chunks[0]->[0][0], $chunks[1]->[0][1]);
-                        push @expressions, [ [ @indexes ], $expression, { 
flags => DURATION_TYPE } ];
-                        $skip{$_} = true foreach ($indexes[0] .. $indexes[1]);
-                        redo DURATION;
-                    }
-                }
-            }
-        }
+        $self->_extract_duration($extract_string, \@tokens, \@expressions, 
\%skip);
     }
 
     my (%expand, %lengths);
@@ -185,6 +148,47 @@
     return $self->_finalize_expressions(\@expressions, \@tokens);
 }
 
+sub _extract_duration
+{
+    my $self = shift;
+    my ($extract_string, $tokens, $expressions, $skip) = @_;
+
+    my $timespan_sep = $self->{data}->__timespan('literal');
+
+    my @strings = grep /\S/, map trim($_), split /\b $timespan_sep \b/ix, 
$extract_string;
+    if (@strings) {
+        my $index = 0;
+        my @indexes;
+        foreach my $string (@strings) {
+            my @string_tokens = split /\s+/, $string;
+            push @indexes, [ $index, $index + $#string_tokens ];
+            $index += $#string_tokens + 1;
+            $index++ while defined $tokens->[$index] && $tokens->[$index] =~ 
/^$timespan_sep$/i;
+        }
+        DURATION: {
+            for (my $i = 0; $i <= $#strings - 1; $i++) {
+                next unless $extract_duration->($skip, \@indexes, $i);
+                my $save_expression = false;
+                my @chunks;
+                foreach my $extract (qw(_first_to_last_extract 
_from_count_to_count_extract)) {
+                    if ($self->$extract($get_range->(\@strings, $i), 
$get_range->(\@indexes, $i), $tokens, \@chunks)) {
+                        $save_expression = true;
+                        last;
+                    }
+                }
+                if ($save_expression) {
+                    my $timespan_sep_index = $chunks[0]->[0][1] + 1;
+                    my $expression = join ' ', ($chunks[0]->[1], 
$tokens->[$timespan_sep_index], $chunks[1]->[1]);
+                    my @indexes = ($chunks[0]->[0][0], $chunks[1]->[0][1]);
+                    push @$expressions, [ [ @indexes ], $expression, { flags 
=> DURATION_TYPE } ];
+                    $skip->{$_} = true foreach ($indexes[0] .. $indexes[1]);
+                    redo DURATION;
+                }
+            }
+        }
+    }
+}
+
 sub _finalize_expressions
 {
     my $self = shift;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural/Utils.pm 
new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural/Utils.pm
--- old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural/Utils.pm       
2020-09-23 21:29:34.000000000 +0200
+++ new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural/Utils.pm       
2021-03-19 21:14:02.000000000 +0100
@@ -2,9 +2,13 @@
 
 use strict;
 use warnings;
+use base qw(Exporter);
 use boolean qw(true false);
 
-our $VERSION = '0.05';
+our ($VERSION, @EXPORT_OK);
+
+$VERSION = '0.07';
+@EXPORT_OK = qw(trim);
 
 sub _valid_date
 {
@@ -73,12 +77,22 @@
       keys %$modified;
 }
 
+sub trim
+{
+    local $_ = ref $_[0] eq 'SCALAR' ? ${$_[0]} : $_[0];
+
+    s/^\s+//;
+    s/\s+$//;
+
+    return ref $_[0] eq 'SCALAR' ? do { ${$_[0]} = $_; '' } : $_;
+}
+
 1;
 __END__
 
 =head1 NAME
 
-DateTime::Format::Natural::Utils - Handy utility methods
+DateTime::Format::Natural::Utils - Handy utility functions/methods
 
 =head1 SYNOPSIS
 
@@ -86,7 +100,7 @@
 
 =head1 DESCRIPTION
 
-The C<DateTime::Format::Natural::Utils> class consists of utility methods.
+The C<DateTime::Format::Natural::Utils> class consists of utility 
functions/methods.
 
 =head1 SEE ALSO
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural.pm 
new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural.pm
--- old/DateTime-Format-Natural-1.11/lib/DateTime/Format/Natural.pm     
2020-09-23 21:29:34.000000000 +0200
+++ new/DateTime-Format-Natural-1.12/lib/DateTime/Format/Natural.pm     
2021-03-19 21:14:02.000000000 +0100
@@ -21,7 +21,9 @@
 use Scalar::Util qw(blessed);
 use Storable qw(dclone);
 
-our $VERSION = '1.11';
+use DateTime::Format::Natural::Utils qw(trim);
+
+our $VERSION = '1.12';
 
 validation_options(
     on_fail => sub
@@ -285,12 +287,7 @@
         (${$params->{string}}) = @_;
     }
 
-    ${$params->{string}} = do {
-        local $_ = ${$params->{string}};
-        s/^\s+//;
-        s/\s+$//;
-        $_
-    };
+    trim($params->{string});
 }
 
 sub _parse_init
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/DateTime-Format-Natural-1.11/t/13-parse_assert.t 
new/DateTime-Format-Natural-1.12/t/13-parse_assert.t
--- old/DateTime-Format-Natural-1.11/t/13-parse_assert.t        2020-09-23 
21:29:34.000000000 +0200
+++ new/DateTime-Format-Natural-1.12/t/13-parse_assert.t        2021-03-19 
21:14:02.000000000 +0100
@@ -5,7 +5,7 @@
 use boolean qw(true false);
 
 use DateTime::Format::Natural;
-use Test::More tests => 17;
+use Test::More tests => 18;
 
 {
     # Assert for prefixed dates that an extracted unit which is
@@ -115,3 +115,10 @@
     $parser->parse_datetime('8/10');
     ok(!$parser->success, 'parsing month/day with an explicit ymd-format 
failed');
 }
+
+{
+    # Assert that error() returns '' on success.
+    my $parser = DateTime::Format::Natural->new;
+    $parser->parse_datetime('now'); # success
+    is($parser->error, '', "error() returns '' on success");
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/DateTime-Format-Natural-1.11/t/14-extract_expression.t 
new/DateTime-Format-Natural-1.12/t/14-extract_expression.t
--- old/DateTime-Format-Natural-1.11/t/14-extract_expression.t  2020-09-23 
21:29:34.000000000 +0200
+++ new/DateTime-Format-Natural-1.12/t/14-extract_expression.t  2021-03-19 
21:14:02.000000000 +0100
@@ -98,7 +98,12 @@
     { 'sat @ 2 to sun @ 6'              => [ 'sat 2:00 to sun 6:00'           
] },
 );
 
-foreach my $set (\@strings, \@expanded, \@rewrite, \@punctuation, \@spaces, 
\@duration, \@durations) {
+# Check that looping works for those kind of durations.
+my @assert = (
+    { 'jan 1st to 31st foo first to last day of dec' => [ 'jan 1st to 31st', 
'first to last day of dec' ] },
+);
+
+foreach my $set (\@strings, \@expanded, \@rewrite, \@punctuation, \@spaces, 
\@duration, \@durations, \@assert) {
     compare($set);
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/DateTime-Format-Natural-1.11/t/pod-coverage.t 
new/DateTime-Format-Natural-1.12/t/pod-coverage.t
--- old/DateTime-Format-Natural-1.11/t/pod-coverage.t   2020-09-23 
21:29:34.000000000 +0200
+++ new/DateTime-Format-Natural-1.12/t/pod-coverage.t   2021-03-19 
21:14:02.000000000 +0100
@@ -18,4 +18,4 @@
 _find_modules(realpath(catfile($Bin, updir, 'lib')), \@modules, \@exclude);
 @modules = sort @modules;
 plan tests => scalar @modules;
-pod_coverage_ok($_) foreach @modules;
+pod_coverage_ok($_, { trustme => [qr/^trim$/] }) foreach @modules;

Reply via email to