r72542 - in /trunk/libdatetime-format-natural-perl: ./ debian/ lib/DateTime/Format/ lib/DateTime/Format/Natural/ lib/DateTime/Format/Natural/Lang/ t/

angelabad-guest at users.alioth.debian.org angelabad-guest at users.alioth.debian.org
Tue Apr 12 10:17:36 UTC 2011


Author: angelabad-guest
Date: Tue Apr 12 10:17:17 2011
New Revision: 72542

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=72542
Log:
* New upstream release
* debian/control: Remove libmodule-build-perl from B-D-I

Added:
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Extract.pm
      - copied unchanged from r72541, branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Extract.pm
    trunk/libdatetime-format-natural-perl/t/12-extract_expression.t
      - copied unchanged from r72541, branches/upstream/libdatetime-format-natural-perl/current/t/12-extract_expression.t
    trunk/libdatetime-format-natural-perl/t/13-regression.t
      - copied unchanged from r72541, branches/upstream/libdatetime-format-natural-perl/current/t/13-regression.t
    trunk/libdatetime-format-natural-perl/t/14-state.t
      - copied unchanged from r72541, branches/upstream/libdatetime-format-natural-perl/current/t/14-state.t
    trunk/libdatetime-format-natural-perl/t/15-trace.t
      - copied unchanged from r72541, branches/upstream/libdatetime-format-natural-perl/current/t/15-trace.t
Removed:
    trunk/libdatetime-format-natural-perl/t/12-regression.t
    trunk/libdatetime-format-natural-perl/t/13-state.t
    trunk/libdatetime-format-natural-perl/t/14-trace.t
Modified:
    trunk/libdatetime-format-natural-perl/Changes
    trunk/libdatetime-format-natural-perl/MANIFEST
    trunk/libdatetime-format-natural-perl/META.yml
    trunk/libdatetime-format-natural-perl/Makefile.PL
    trunk/libdatetime-format-natural-perl/README
    trunk/libdatetime-format-natural-perl/debian/changelog
    trunk/libdatetime-format-natural-perl/debian/control
    trunk/libdatetime-format-natural-perl/debian/copyright
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Calc.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Formatted.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm
    trunk/libdatetime-format-natural-perl/t/01-parse.t

Modified: trunk/libdatetime-format-natural-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Changes?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Changes (original)
+++ trunk/libdatetime-format-natural-perl/Changes Tue Apr 12 10:17:17 2011
@@ -1,4 +1,35 @@
 Revision history for Perl extension DateTime::Format::Natural.
+
+0.94  2011-04-02  <schubiger at cpan.org>
+
+ - Merged development version to stable.
+
+0.93_02  2011-03-31  <schubiger at cpan.org>
+
+ - Set month and implicit day explicitly to avoid overlap parse
+   failures; add a regression test. [reported by Chifung Fan]
+
+ - Keep the minute or higher precision requirement when extracting
+   one token time expressions, but undo the grammar change.
+
+ - Test one token time expression with precision in hour.
+
+ - Use more descriptive variable names within the extract class.
+
+0.93_01  2011-03-21  <schubiger at cpan.org>
+
+ - Introduce a class to extract parsable expressions from strings.
+   [suggested by Colm Dougan]
+
+ - Add and document the extract_datetime() method.
+
+ - Test extracting parsable expressions.
+
+ - Require precision in hour or higher for one token time expressions,
+   otherwise extracting expressions would be impeded.
+
+ - Move the formatted string regex to the grammar class;
+   furthermore, move the according checks to the formatted class.
 
 0.93  2011-02-04  <schubiger at cpan.org>
 

Modified: trunk/libdatetime-format-natural-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/MANIFEST?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/MANIFEST (original)
+++ trunk/libdatetime-format-natural-perl/MANIFEST Tue Apr 12 10:17:17 2011
@@ -7,6 +7,7 @@
 lib/DateTime/Format/Natural/Compat.pm
 lib/DateTime/Format/Natural/Duration.pm
 lib/DateTime/Format/Natural/Duration/Checks.pm
+lib/DateTime/Format/Natural/Extract.pm
 lib/DateTime/Format/Natural/Formatted.pm
 lib/DateTime/Format/Natural/Helpers.pm
 lib/DateTime/Format/Natural/Lang/Base.pm
@@ -31,8 +32,9 @@
 t/09-parse_success.t
 t/10-parse_failure.t
 t/11-parse_assert.t
-t/12-regression.t
-t/13-state.t
-t/14-trace.t
+t/12-extract_expression.t
+t/13-regression.t
+t/14-state.t
+t/15-trace.t
 t/pod-coverage.t
 t/pod.t

Modified: trunk/libdatetime-format-natural-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/META.yml?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/META.yml (original)
+++ trunk/libdatetime-format-natural-perl/META.yml Tue Apr 12 10:17:17 2011
@@ -1,6 +1,6 @@
 ---
 name: DateTime-Format-Natural
-version: 0.93
+version: 0.94
 author:
   - 'Steven Schubiger <schubiger at cpan.org>'
 abstract: Create machine readable date/time with natural parsing logic
@@ -31,17 +31,17 @@
   Test::Pod: 1.14
   Test::Pod::Coverage: 1.04
 configure_requires:
-  Module::Build: 0.34
+  Module::Build: 0.340201
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: 0.93
+    version: 0.94
   DateTime::Format::Natural::Aliases:
     file: lib/DateTime/Format/Natural/Aliases.pm
     version: 0.03
   DateTime::Format::Natural::Calc:
     file: lib/DateTime/Format/Natural/Calc.pm
-    version: 1.37
+    version: 1.38
   DateTime::Format::Natural::Compat:
     file: lib/DateTime/Format/Natural/Compat.pm
     version: 0.07
@@ -51,9 +51,12 @@
   DateTime::Format::Natural::Duration::Checks:
     file: lib/DateTime/Format/Natural/Duration/Checks.pm
     version: 0.01
+  DateTime::Format::Natural::Extract:
+    file: lib/DateTime/Format/Natural/Extract.pm
+    version: 0.02
   DateTime::Format::Natural::Formatted:
     file: lib/DateTime/Format/Natural/Formatted.pm
-    version: 0.05
+    version: 0.06
   DateTime::Format::Natural::Helpers:
     file: lib/DateTime/Format/Natural/Helpers.pm
     version: 0.06
@@ -62,7 +65,7 @@
     version: 1.06
   DateTime::Format::Natural::Lang::EN:
     file: lib/DateTime/Format/Natural/Lang/EN.pm
-    version: 1.47
+    version: 1.49
   DateTime::Format::Natural::Test:
     file: lib/DateTime/Format/Natural/Test.pm
     version: 0.07
@@ -72,7 +75,7 @@
   DateTime::Format::Natural::Wrappers:
     file: lib/DateTime/Format/Natural/Wrappers.pm
     version: 0.02
-generated_by: Module::Build version 0.34
+generated_by: Module::Build version 0.340201
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
   version: 1.4

Modified: trunk/libdatetime-format-natural-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Makefile.PL?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Makefile.PL (original)
+++ trunk/libdatetime-format-natural-perl/Makefile.PL Tue Apr 12 10:17:17 2011
@@ -1,4 +1,4 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.34
+# Note: this file was auto-generated by Module::Build::Compat version 0.340201
 use ExtUtils::MakeMaker;
 WriteMakefile
 (

Modified: trunk/libdatetime-format-natural-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/README?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/README (original)
+++ trunk/libdatetime-format-natural-perl/README Tue Apr 12 10:17:17 2011
@@ -6,6 +6,9 @@
      use DateTime::Format::Natural;
 
      $parser = DateTime::Format::Natural->new;
+
+     $date_string  = $parser->extract_datetime($extract_string);
+     @date_strings = $parser->extract_datetime($extract_string);
 
      $dt = $parser->parse_datetime($date_string);
      @dt = $parser->parse_datetime_duration($date_string);
@@ -31,7 +34,6 @@
 
 CONSTRUCTOR
   new
-
     Creates a new `DateTime::Format::Natural' object. Arguments to `new()'
     are options and not necessarily required.
 
@@ -71,7 +73,6 @@
 
 METHODS
   parse_datetime
-
     Returns a DateTime object constructed from a human readable date/time
     string.
 
@@ -82,7 +83,6 @@
         The date string.
 
   parse_datetime_duration
-
     Returns one or two DateTime objects constructed from a human readable
     date/time string which may contain timespans/durations. *Same* interface
     and options as `parse_datetime()', but should be explicitly called in
@@ -91,17 +91,27 @@
      @dt = $parser->parse_datetime_duration($date_string);
      @dt = $parser->parse_datetime_duration(string => $date_string);
 
+  extract_datetime
+    Returns parsable date/time substrings (also known as expressions)
+    extracted from the string provided; in scalar context only the first
+    parsable substring is returned, whereas in list context all parsable
+    substrings are returned. Each extracted substring can then be passed to
+    the `parse_datetime()'/ `parse_datetime_duration()' methods.
+
+     $date_string  = $parser->extract_datetime($extract_string);
+     @date_strings = $parser->extract_datetime($extract_string);
+     # or
+     $date_string  = $parser->extract_datetime(string => $extract_string);
+     @date_strings = $parser->extract_datetime(string => $extract_string);
+
   success
-
     Returns a boolean indicating success or failure for parsing the
     date/time string given.
 
   error
-
     Returns the error message if the parsing did not succeed.
 
   trace
-
     Returns one or two strings with the grammar keyword for the valid
     expression parsed, traces of methods which were called within the Calc
     class and a summary how often certain units have been modified. More
@@ -168,6 +178,8 @@
      Vladimir Marek
      Rod Taylor
      Tim Esselens
+     Colm Dougan
+     Chifung Fan
 
 SEE ALSO
     DateTime, Date::Calc, http://datetime.perl.org

Modified: trunk/libdatetime-format-natural-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/changelog?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/changelog (original)
+++ trunk/libdatetime-format-natural-perl/debian/changelog Tue Apr 12 10:17:17 2011
@@ -1,3 +1,10 @@
+libdatetime-format-natural-perl (0.94-1) unstable; urgency=low
+
+  * New upstream release
+  * debian/control: Remove libmodule-build-perl from B-D-I
+
+ -- Angel Abad <angelabad at gmail.com>  Tue, 12 Apr 2011 12:16:53 +0200
+
 libdatetime-format-natural-perl (0.93-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libdatetime-format-natural-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/control?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/control (original)
+++ trunk/libdatetime-format-natural-perl/debian/control Tue Apr 12 10:17:17 2011
@@ -11,8 +11,7 @@
  libtest-mocktime-perl,
  libtest-pod-coverage-perl,
  libtest-pod-perl,
- perl,
- perl (>= 5.10.1) | libmodule-build-perl (>= 0.340000)
+ perl
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
 Uploaders: Ansgar Burchardt <ansgar at debian.org>,
  gregor herrmann <gregoa at debian.org>,

Modified: trunk/libdatetime-format-natural-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/copyright?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/copyright (original)
+++ trunk/libdatetime-format-natural-perl/debian/copyright Tue Apr 12 10:17:17 2011
@@ -20,12 +20,12 @@
      See http://www.perl.com/perl/misc/Artistic.html
 
 Files: debian/*
-Copyright: 2008, 2009, Ansgar Burchardt <ansgar at debian.org>
+Copyright: 2008-2009, Ansgar Burchardt <ansgar at debian.org>
  2008, gregor herrmann <gregoa at debian.org>
  2009, 2010, Jonathan Yu <jawnsy at cpan.org>
  2009-2011, Salvatore Bonaccorso <carnil at debian.org>
  2009, Rene Mayorga <rmayorga at debian.org>
- 2010, 2011, Angel Abad <angelabad at gmail.com>
+ 2010-2011, Angel Abad <angelabad at gmail.com>
 License: Artistic or GPL-1+
 
 License: Artistic

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm Tue Apr 12 10:17:17 2011
@@ -6,6 +6,7 @@
     DateTime::Format::Natural::Aliases
     DateTime::Format::Natural::Calc
     DateTime::Format::Natural::Duration
+    DateTime::Format::Natural::Extract
     DateTime::Format::Natural::Formatted
     DateTime::Format::Natural::Helpers
 );
@@ -18,7 +19,7 @@
 use Scalar::Util qw(blessed);
 use Storable qw(dclone);
 
-our $VERSION = '0.93';
+our $VERSION = '0.94';
 
 validation_options(
     on_fail => sub
@@ -139,27 +140,22 @@
     $self->_rewrite_aliases(\$date_string);
     $date_string =~ tr/,//d;
 
-    my ($formatted) = $date_string =~ m!^((?:\d+?[-./])+ (?:\d+?)) \b!x;
-
-    my %count;
-    if (defined $formatted) {
-        my @count = $formatted =~ m![-./]!g;
-        $count{$_}++ foreach @count;
-    }
+    my ($formatted) = $date_string =~ $self->{data}->__regexes('format');
+    my %count = $self->_count_separators($formatted);
 
     $self->{tokens} = [];
     $self->{traces} = [];
 
-    if (scalar keys %count == 1 && $count{(keys %count)[0]} == 2) {
+    if ($self->_check_formatted('ymd', \%count)) {
         my $dt = $self->_parse_formatted_ymd($date_string, \%count);
         return $dt if blessed($dt);
     }
-    elsif (scalar keys %count == 1 && $count{(keys %count)[0]} == 1 && (keys %count)[0] eq '/') {
+    elsif ($self->_check_formatted('md', \%count)) {
         my $dt = $self->_parse_formatted_md($date_string);
         return $dt if blessed($dt);
 
         if ($self->{Prefer_future}) {
-            $self->_advance_future(qw(md));
+            $self->_advance_future('md');
         }
     }
     elsif ($date_string =~ /^([+-]) (\d+?) ([a-zA-Z]+)$/x) {
@@ -303,6 +299,18 @@
     }
 
     return @queue;
+}
+
+sub extract_datetime
+{
+    my $self = shift;
+
+    my $extract_string;
+    $self->_params_init(@_, { string => \$extract_string });
+
+    my @expressions = $self->_extract_expressions($extract_string);
+
+    return wantarray ? @expressions : $expressions[0];
 }
 
 sub success
@@ -565,6 +573,9 @@
 
  $parser = DateTime::Format::Natural->new;
 
+ $date_string  = $parser->extract_datetime($extract_string);
+ @date_strings = $parser->extract_datetime($extract_string);
+
  $dt = $parser->parse_datetime($date_string);
  @dt = $parser->parse_datetime_duration($date_string);
 
@@ -664,6 +675,20 @@
 
  @dt = $parser->parse_datetime_duration($date_string);
  @dt = $parser->parse_datetime_duration(string => $date_string);
+
+=head2 extract_datetime
+
+Returns parsable date/time substrings (also known as expressions) extracted
+from the string provided; in scalar context only the first parsable substring
+is returned, whereas in list context all parsable substrings are returned.
+Each extracted substring can then be passed to the C<parse_datetime()>/
+C<parse_datetime_duration()> methods.
+
+ $date_string  = $parser->extract_datetime($extract_string);
+ @date_strings = $parser->extract_datetime($extract_string);
+ # or
+ $date_string  = $parser->extract_datetime(string => $extract_string);
+ @date_strings = $parser->extract_datetime(string => $extract_string);
 
 =head2 success
 
@@ -743,6 +768,8 @@
  Vladimir Marek
  Rod Taylor
  Tim Esselens
+ Colm Dougan
+ Chifung Fan
 
 =head1 SEE ALSO
 

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Calc.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Calc.pm?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Calc.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Calc.pm Tue Apr 12 10:17:17 2011
@@ -8,7 +8,7 @@
     DateTime::Format::Natural::Wrappers
 );
 
-our $VERSION = '1.37';
+our $VERSION = '1.38';
 
 use constant MORNING   => '08';
 use constant AFTERNOON => '14';
@@ -116,6 +116,7 @@
     $self->_register_trace;
     my $opts = pop;
     my ($value) = @_;
+    $self->{datetime}->set(day => 1) if $opts->{unit} eq 'month';
     if ($self->_valid_date($opts->{unit} => $value)) {
         $self->_set($opts->{unit} => $value);
     }

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Formatted.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Formatted.pm?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Formatted.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Formatted.pm Tue Apr 12 10:17:17 2011
@@ -4,7 +4,7 @@
 use warnings;
 use boolean qw(true false);
 
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 sub _parse_formatted_ymd
 {
@@ -150,6 +150,41 @@
     }
 }
 
+sub _count_separators
+{
+    my $self = shift;
+    my ($formatted) = @_;
+
+    my %count;
+    if (defined $formatted) {
+        my @count = $formatted =~ m![-./]!g;
+        $count{$_}++ foreach @count;
+    }
+
+    return %count;
+}
+
+sub _check_formatted
+{
+    my $self = shift;
+    my ($check, $count) = @_;
+
+    my %checks = (
+        ymd => sub
+        {
+            my ($count) = @_;
+            return scalar keys %$count == 1 && $count->{(keys %$count)[0]} == 2;
+        },
+        md => sub
+        {
+            my ($count) = @_;
+            return scalar keys %$count == 1 && $count->{(keys %$count)[0]} == 1 && (keys %$count)[0] eq '/';
+        },
+    );
+
+    return $checks{$check}->($count);
+}
+
 1;
 __END__
 

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm Tue Apr 12 10:17:17 2011
@@ -13,12 +13,13 @@
 
 use DateTime::Format::Natural::Helpers qw(%flag);
 
-our $VERSION = '1.47';
+our $VERSION = '1.49';
 
 our (%init,
      %timespan,
      %units,
      %suffixes,
+     %regexes,
      %RE,
      %data_weekdays,
      %data_weekdays_abbrev,
@@ -37,6 +38,7 @@
 %timespan = (literal => 'to');
 %units    = (ordered => [ qw(second minute hour day week month year) ]);
 %suffixes = (ordinal => join '|', qw(st nd rd th d));
+%regexes  = (format  => qr!^((?:\d+?[-./])+ (?:\d+?)) \b!x);
 
 %RE = (number    => qr/^(\d+)$/,
        year      => qr/^(\d{4})$/,
@@ -4570,7 +4572,7 @@
 
 Below are some examples of human readable date/time input in english (be aware
 that the parser does not distinguish between lower/upper case; furthermore,
-times are also parseable with precision in seconds):
+times are also parsable with precision in seconds):
 
 =head2 Simple
 

Modified: trunk/libdatetime-format-natural-perl/t/01-parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/01-parse.t?rev=72542&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/01-parse.t (original)
+++ trunk/libdatetime-format-natural-perl/t/01-parse.t Tue Apr 12 10:17:17 2011
@@ -302,6 +302,7 @@
     { '3 jan 2000'                 => '03.01.2000 00:00:00'     },
     { '2010 october 28'            => '28.10.2010 00:00:00'     },
     { '27/5/1979'                  => '27.05.1979 00:00:00'     },
+    { '6'                          => '24.11.2006 06:00:00'     },
     { '4:00'                       => '24.11.2006 04:00:00'     },
     { '17:00'                      => '24.11.2006 17:00:00'     },
     { '3:20:00'                    => '24.11.2006 03:20:00'     },
@@ -309,7 +310,7 @@
     { '+2d'                        => '26.11.2006 01:13:08'     },
 );
 
-_run_tests(463, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare);
+_run_tests(464, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare);
 
 sub compare
 {




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