r37306 - in /trunk/libdbix-class-datetime-epoch-perl: Build.PL Changes MANIFEST META.yml Makefile.PL README debian/changelog inc/ lib/DBIx/Class/DateTime/Epoch.pm t/01-use.t t/02-schema.t t/03-compat.t t/98-pod_coverage.t t/99-pod.t t/lib/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Tue Jun 2 17:56:23 UTC 2009
Author: gregoa
Date: Tue Jun 2 17:56:18 2009
New Revision: 37306
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=37306
Log:
New upstream release.
Added:
trunk/libdbix-class-datetime-epoch-perl/inc/
- copied from r37305, branches/upstream/libdbix-class-datetime-epoch-perl/current/inc/
trunk/libdbix-class-datetime-epoch-perl/t/02-schema.t
- copied unchanged from r37305, branches/upstream/libdbix-class-datetime-epoch-perl/current/t/02-schema.t
trunk/libdbix-class-datetime-epoch-perl/t/03-compat.t
- copied unchanged from r37305, branches/upstream/libdbix-class-datetime-epoch-perl/current/t/03-compat.t
trunk/libdbix-class-datetime-epoch-perl/t/lib/
- copied from r37305, branches/upstream/libdbix-class-datetime-epoch-perl/current/t/lib/
Removed:
trunk/libdbix-class-datetime-epoch-perl/Build.PL
Modified:
trunk/libdbix-class-datetime-epoch-perl/Changes
trunk/libdbix-class-datetime-epoch-perl/MANIFEST
trunk/libdbix-class-datetime-epoch-perl/META.yml
trunk/libdbix-class-datetime-epoch-perl/Makefile.PL
trunk/libdbix-class-datetime-epoch-perl/README
trunk/libdbix-class-datetime-epoch-perl/debian/changelog
trunk/libdbix-class-datetime-epoch-perl/lib/DBIx/Class/DateTime/Epoch.pm
trunk/libdbix-class-datetime-epoch-perl/t/01-use.t
trunk/libdbix-class-datetime-epoch-perl/t/98-pod_coverage.t
trunk/libdbix-class-datetime-epoch-perl/t/99-pod.t
Modified: trunk/libdbix-class-datetime-epoch-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/Changes?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/Changes (original)
+++ trunk/libdbix-class-datetime-epoch-perl/Changes Tue Jun 2 17:56:18 2009
@@ -1,4 +1,17 @@
Revision history for Perl extension DBIx::Class::DateTime::Epoch.
+
+0.05 Mon Jun 01 2009
+ [ THING THAT WILL NO LONGER BREAK YOUR CODE ]
+ - added back-compat for the "epoch => 1", etc syntax
+
+0.04 Tue May 26 2009
+ [ THINGS THAT WILL BREAK YOUR CODE ]
+ - refactor module to itegrate with InflateColumn::DateTime and TimeStamp.
+ Requires DBIx::Class 0.08103 and DBIx::Class::TimeStamp 0.07.
+ Please read the new documentation.
+
+ [ ENHANCEMENTS ]
+ - switch to Module::Install
0.03 Wed Apr 25 2007
- don't override user-supplied values for update()
Modified: trunk/libdbix-class-datetime-epoch-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/MANIFEST?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/MANIFEST (original)
+++ trunk/libdbix-class-datetime-epoch-perl/MANIFEST Tue Jun 2 17:56:18 2009
@@ -1,10 +1,22 @@
-Build.PL
Changes
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
lib/DBIx/Class/DateTime/Epoch.pm
Makefile.PL
MANIFEST This list of files
META.yml
README
t/01-use.t
+t/02-schema.t
+t/03-compat.t
t/98-pod_coverage.t
t/99-pod.t
+t/lib/MySchema.pm
+t/lib/MySchema/Foo.pm
+t/lib/MySchema/FooCompat.pm
Modified: trunk/libdbix-class-datetime-epoch-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/META.yml?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/META.yml (original)
+++ trunk/libdbix-class-datetime-epoch-perl/META.yml Tue Jun 2 17:56:18 2009
@@ -1,22 +1,30 @@
---
-name: DBIx-Class-DateTime-Epoch
-version: 0.03
+abstract: 'Automatic inflation/deflation of epoch-based columns to/from DateTime objects'
author:
- 'Brian Cassidy <bricas at cpan.org>'
-abstract: Automatic inflation/deflation of epoch-based DateTime objects for DBIx::Class
+build_requires:
+ DBICx::TestDatabase: 0
+ ExtUtils::MakeMaker: 6.42
+ Test::More: 0
+configure_requires:
+ ExtUtils::MakeMaker: 6.42
+distribution_type: module
+generated_by: 'Module::Install version 0.91'
license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
+name: DBIx-Class-DateTime-Epoch
+no_index:
+ directory:
+ - inc
+ - t
+requires:
+ DBIx::Class: 0.08103
+ DBIx::Class::TimeStamp: 0.07
+ DateTime: 0
+ perl: 5.6.1
resources:
license: http://dev.perl.org/licenses/
-requires:
- DBIx::Class: 0
- DateTime: 0
-build_requires:
- Test::More: 0
-provides:
- DBIx::Class::DateTime::Epoch:
- file: lib/DBIx/Class/DateTime/Epoch.pm
- version: 0.03
-generated_by: Module::Build version 0.2807
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
+ repository: http://github.com/bricas/dbix-class-datetime-epoch
+version: 0.05
Modified: trunk/libdbix-class-datetime-epoch-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/Makefile.PL?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/Makefile.PL (original)
+++ trunk/libdbix-class-datetime-epoch-perl/Makefile.PL Tue Jun 2 17:56:18 2009
@@ -1,16 +1,21 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.03
-use ExtUtils::MakeMaker;
-WriteMakefile
-(
- 'PL_FILES' => {},
- 'INSTALLDIRS' => 'site',
- 'NAME' => 'DBIx::Class::DateTime::Epoch',
- 'EXE_FILES' => [],
- 'VERSION_FROM' => 'lib/DBIx/Class/DateTime/Epoch.pm',
- 'PREREQ_PM' => {
- 'Test::More' => 0,
- 'DateTime' => 0,
- 'DBIx::Class' => 0
- }
- )
-;
+use inc::Module::Install 0.87;
+
+if( -e 'MANIFEST.SKIP' ) {
+ system( 'pod2text lib/DBIx/Class/DateTime/Epoch.pm > README' );
+}
+
+perl_version '5.006001';
+
+name 'DBIx-Class-DateTime-Epoch';
+all_from 'lib/DBIx/Class/DateTime/Epoch.pm';
+
+requires 'DBIx::Class' => '0.08103'; # InflateColumn::DateTime overriding possible
+requires 'DBIx::Class::TimeStamp' => '0.07'; # removes data_type checking
+requires 'DateTime';
+
+test_requires 'Test::More';
+test_requires 'DBICx::TestDatabase';
+
+repository 'http://github.com/bricas/dbix-class-datetime-epoch';
+
+WriteAll;
Modified: trunk/libdbix-class-datetime-epoch-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/README?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/README (original)
+++ trunk/libdbix-class-datetime-epoch-perl/README Tue Jun 2 17:56:18 2009
@@ -1,67 +1,84 @@
NAME
DBIx::Class::DateTime::Epoch - Automatic inflation/deflation of
- epoch-based DateTime objects for DBIx::Class
+ epoch-based columns to/from DateTime objects
SYNOPSIS
- package foo;
-
- use base qw( DBIx::Class );
-
- __PACKAGE__->load_components( qw( DateTime::Epoch Core ) );
+ package MySchema::Foo;
+
+ use base qw( DBIx::Class );
+
+ __PACKAGE__->load_components( qw( DateTime::Epoch TimeStamp Core ) );
__PACKAGE__->add_columns(
name => {
data_type => 'varchar',
- size => 10
+ size => 10,
},
- bar => {
- data_type => 'bigint',
- epoch => 1
+ bar => { # epoch stored as an int
+ data_type => 'bigint',
+ inflate_datetime => 1,
},
+ baz => { # epoch stored as a string
+ data_type => 'varchar',
+ size => 50,
+ inflate_datetime => 'epoch',
+ },
+ # working in conjunction with DBIx::Class::TimeStamp
creation_time => {
- data_type => 'bigint',
- epoch => 'ctime'
+ data_type => 'bigint',
+ inflate_datetime => 1,
+ set_on_create => 1,
},
modification_time => {
- data_type => 'bigint',
- epoch => 'mtime'
+ data_type => 'bigint',
+ inflate_datetime => 1,
+ set_on_create => 1,
+ set_on_update => 1,
}
);
DESCRIPTION
- This module automatically inflates/deflates DateTime objects
- corresponding to applicable columns. Columns may also be defined to
- specify their nature, such as columns representing a creation time (set
- at time of insertion) or a modification time (set at time of every
- update).
+ This module automatically inflates/deflates DateTime objects from/to
+ epoch values for the specified columns. This module is essentially an
+ extension to DBIx::Class::InflateColumn::DateTime so all of the
+ settings, including "locale" and "timezone", are also valid.
+
+ A column will be recognized as an epoch time given one of the following
+ scenarios:
+
+ * "data_type" is an "int" of some sort and "inflate_datetime" is also
+ set to a true value
+
+ * "data_type" is some other value (e.g. "varchar") and
+ "inflate_datetime" is explicitly set to "epoch".
+
+ DBIx::Class::TimeStamp can also be used in conjunction with this module
+ to support epoch-based columns that are automatically set on creation of
+ a row and updated subsequent modifications.
METHODS
- register_column
- This method will automatically add inflation and deflation rules to a
- column if an epoch value has been set in the column's definition. If the
- epoch value is 'ctime' (creation time) or 'mtime' (modification time),
- it will be registered as such for later use by the insert and the update
- methods.
+ add_columns( )
+ Provides backwards compatibility with the older DateTime::Epoch API.
- insert
- This method will set the value of all registered creation time columns
- to the current time. No changes will be made to a column whose value has
- already been set.
+ _inflate_to_datetime( )
+ Overrides column inflation to use "Datetime->from_epoch".
- update
- This method will set the value of all registered modification time
- columns to the current time. This will overwrite a column's value, even
- if it has been already set.
+ _deflate_from_datetime( )
+ Overrides column deflation to call "epoch()" on the column value.
SEE ALSO
- * DateTime
- * DBIx::Class
+ * DBIx::Class
-AUTHOR
- * Brian Cassidy <bricas at cpan.org>
- * Adam Paynter <adapay at cpan.org>
+ * DBIx::Class::TimeStamp
+
+ * DateTime
+
+AUTHORS
+ Brian Cassidy <bricas at cpan.org>
+
+ Adam Paynter <adapay at cpan.org>
COPYRIGHT AND LICENSE
- Copyright 2006 by Brian Cassidy
+ Copyright 2006-2009 by Brian Cassidy
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Modified: trunk/libdbix-class-datetime-epoch-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/debian/changelog?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/debian/changelog (original)
+++ trunk/libdbix-class-datetime-epoch-perl/debian/changelog Tue Jun 2 17:56:18 2009
@@ -1,8 +1,9 @@
-libdbix-class-datetime-epoch-perl (0.03-2) UNRELEASED; urgency=low
+libdbix-class-datetime-epoch-perl (0.05-1) UNRELEASED; urgency=low
* debian/control: Added: ${misc:Depends} to Depends: field.
+ * New upstream release.
- -- gregor herrmann <gregoa at debian.org> Sat, 06 Dec 2008 18:36:30 +0100
+ -- gregor herrmann <gregoa at debian.org> Tue, 02 Jun 2009 19:54:17 +0200
libdbix-class-datetime-epoch-perl (0.03-1) unstable; urgency=low
Modified: trunk/libdbix-class-datetime-epoch-perl/lib/DBIx/Class/DateTime/Epoch.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/lib/DBIx/Class/DateTime/Epoch.pm?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/lib/DBIx/Class/DateTime/Epoch.pm (original)
+++ trunk/libdbix-class-datetime-epoch-perl/lib/DBIx/Class/DateTime/Epoch.pm Tue Jun 2 17:56:18 2009
@@ -3,144 +3,157 @@
use strict;
use warnings;
-our $VERSION = '0.03';
+our $VERSION = '0.05';
use base qw( DBIx::Class );
use DateTime;
+__PACKAGE__->load_components( qw( InflateColumn::DateTime ) );
+
+# back compat
+sub add_columns {
+ my( $class, @cols ) = @_;
+ my @columns;
+
+ while (my $col = shift @cols) {
+ my $info = ref $cols[0] ? shift @cols : {};
+
+ if( my $type = delete $info->{ epoch } ) {
+ $info->{ inflate_datetime } = 'epoch';
+
+ if( $type =~ m{^[cm]time$} ) {
+ __PACKAGE__->load_components( 'TimeStamp' );
+ $info->{ set_on_create } = 1;
+ $info->{ set_on_update } = 1 if $type eq 'mtime';
+ }
+ }
+
+ push @columns, $col => $info;
+
+ }
+
+ $class->next::method( @columns );
+}
+
+sub _inflate_to_datetime {
+ my( $self, $value, $info, @rest ) = @_;
+ $self->next::method( $value, $info, @rest )
+ unless $info->{ data_type } =~ m{int} || $info->{ inflate_datetime } eq 'epoch';
+
+ return DateTime->from_epoch( epoch => $value );
+}
+
+sub _deflate_from_datetime {
+ my( $self, $value, $info, @rest ) = @_;
+ $self->next::method( $value, $info, @rest )
+ unless $info->{ data_type } =~ m{int} || $info->{ inflate_datetime } eq 'epoch';
+
+ return $value->epoch;
+}
+
+1;
+
+__END__
+
=head1 NAME
-DBIx::Class::DateTime::Epoch - Automatic inflation/deflation of epoch-based DateTime objects for DBIx::Class
+DBIx::Class::DateTime::Epoch - Automatic inflation/deflation of epoch-based columns to/from DateTime objects
=head1 SYNOPSIS
- package foo;
+ package MySchema::Foo;
use base qw( DBIx::Class );
- __PACKAGE__->load_components( qw( DateTime::Epoch Core ) );
+ __PACKAGE__->load_components( qw( DateTime::Epoch TimeStamp Core ) );
__PACKAGE__->add_columns(
name => {
data_type => 'varchar',
- size => 10
+ size => 10,
},
- bar => {
- data_type => 'bigint',
- epoch => 1
+ bar => { # epoch stored as an int
+ data_type => 'bigint',
+ inflate_datetime => 1,
},
+ baz => { # epoch stored as a string
+ data_type => 'varchar',
+ size => 50,
+ inflate_datetime => 'epoch',
+ },
+ # working in conjunction with DBIx::Class::TimeStamp
creation_time => {
- data_type => 'bigint',
- epoch => 'ctime'
+ data_type => 'bigint',
+ inflate_datetime => 1,
+ set_on_create => 1,
},
modification_time => {
- data_type => 'bigint',
- epoch => 'mtime'
+ data_type => 'bigint',
+ inflate_datetime => 1,
+ set_on_create => 1,
+ set_on_update => 1,
}
);
=head1 DESCRIPTION
-This module automatically inflates/deflates DateTime objects
-corresponding to applicable columns. Columns may also be
-defined to specify their nature, such as columns representing a
-creation time (set at time of insertion) or a modification time
-(set at time of every update).
+This module automatically inflates/deflates DateTime objects from/to epoch
+values for the specified columns. This module is essentially an extension to
+L<DBIx::Class::InflateColumn::DateTime> so all of the settings, including
+C<locale> and C<timezone>, are also valid.
+
+A column will be recognized as an epoch time given one of the following scenarios:
+
+=over 4
+
+=item * C<data_type> is an C<int> of some sort and C<inflate_datetime> is also set to a true value
+
+=item * C<data_type> is some other value (e.g. C<varchar>) and C<inflate_datetime> is explicitly set to C<epoch>.
+
+=back
+
+L<DBIx::Class::TimeStamp> can also be used in conjunction with this module to support
+epoch-based columns that are automatically set on creation of a row and updated subsequent
+modifications.
=head1 METHODS
-=head2 register_column
+=head2 add_columns( )
-This method will automatically add inflation and deflation rules
-to a column if an epoch value has been set in the column's definition.
-If the epoch value is 'ctime' (creation time) or 'mtime'
-(modification time), it will be registered as such for later
-use by the insert and the update methods.
+Provides backwards compatibility with the older DateTime::Epoch API.
-=head2 insert
+=head2 _inflate_to_datetime( )
-This method will set the value of all registered creation time
-columns to the current time. No changes will be made to a column
-whose value has already been set.
+Overrides column inflation to use C<Datetime-E<gt>from_epoch>.
-=head2 update
+=head2 _deflate_from_datetime( )
-This method will set the value of all registered modification time
-columns to the current time. This will overwrite a column's value,
-even if it has been already set.
+Overrides column deflation to call C<epoch()> on the column value.
=head1 SEE ALSO
=over 4
+=item * DBIx::Class
+
+=item * DBIx::Class::TimeStamp
+
=item * DateTime
-
-=item * DBIx::Class
=back
-=head1 AUTHOR
+=head1 AUTHORS
-=over 4
+Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-
-=item * Adam Paynter E<lt>adapay at cpan.orgE<gt>
-
-=back
+Adam Paynter E<lt>adapay at cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
-Copyright 2006 by Brian Cassidy
+Copyright 2006-2009 by Brian Cassidy
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
-__PACKAGE__->mk_classdata( ctime_columns => [ ] );
-__PACKAGE__->mk_classdata( mtime_columns => [ ] );
-
-sub register_column {
- my( $class, $col, $info ) = @_;
- $class->next::method( $col, $info );
-
- if( my $type = $info->{ epoch } ) {
- $class->ctime_columns( [ @{ $class->ctime_columns }, $col ] ) if $type eq 'ctime';
- $class->mtime_columns( [ @{ $class->mtime_columns }, $col ] ) if $type eq 'mtime';
-
- $class->inflate_column(
- $col => {
- inflate => sub { DateTime->from_epoch( epoch => shift ) },
- deflate => sub { shift->epoch }
- }
- );
- }
-}
-
-sub insert {
- my $self = shift;
- my $time = time;
-
- for my $column ( @{ $self->ctime_columns }, @{ $self->mtime_columns } ) {
- next if defined $self->get_column( $column );
- $self->store_column( $column => $time );
- }
-
- $self->next::method( @_ );
-}
-
-sub update {
- my $self = shift;
- my $time = time;
- my %dirty = $self->get_dirty_columns;
-
- for my $column ( @{ $self->mtime_columns } ) {
- next if exists $dirty{ $column };
- $self->set_column( $column => $time );
- }
-
- $self->next::method( @_ );
-}
-
-1;
Modified: trunk/libdbix-class-datetime-epoch-perl/t/01-use.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/t/01-use.t?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/t/01-use.t (original)
+++ trunk/libdbix-class-datetime-epoch-perl/t/01-use.t Tue Jun 2 17:56:18 2009
@@ -1,3 +1,6 @@
+use strict;
+use warnings;
+
use Test::More tests => 1;
BEGIN {
Modified: trunk/libdbix-class-datetime-epoch-perl/t/98-pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/t/98-pod_coverage.t?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/t/98-pod_coverage.t (original)
+++ trunk/libdbix-class-datetime-epoch-perl/t/98-pod_coverage.t Tue Jun 2 17:56:18 2009
@@ -1,3 +1,6 @@
+use strict;
+use warnings;
+
use Test::More;
eval "use Test::Pod::Coverage 1.00";
plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
Modified: trunk/libdbix-class-datetime-epoch-perl/t/99-pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-class-datetime-epoch-perl/t/99-pod.t?rev=37306&op=diff
==============================================================================
--- trunk/libdbix-class-datetime-epoch-perl/t/99-pod.t (original)
+++ trunk/libdbix-class-datetime-epoch-perl/t/99-pod.t Tue Jun 2 17:56:18 2009
@@ -1,3 +1,6 @@
+use strict;
+use warnings;
+
use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
More information about the Pkg-perl-cvs-commits
mailing list