DateTime/Pg.pm

filter: Statementstmt 23.7% 24 / 101 Branchbran 12.5% 2 / 16 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 22.2% 6 / 27 Podpod 100% 7 / 7 totaltotal 22.6% 39 / 172 CC 17 SCAR 19.6
CC
17
Cov
20%
has_date
11.7
has_datetime
11.7
has_duration
11.7
CRAP 7.1
« DateTime/Base.pm ↑ Summary DateTime/MySQL.pm »
1 # $Id: /mirror/coderepos/lang/perl/Class-DBI-Plugin-DateTime/trunk/lib/Class/DBI/Plugin/DateTime/Pg.pm 101061 2009-02-20T09:44:03.572989Z daisuke $
2 #
3 # Copyright (c) 2005 Daisuke Maki <dmaki@cpan.org>
4 # All rights reserved.
5  
6 package Class::DBI::Plugin::DateTime::Pg;
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use base qw(Class::DBI::Plugin::DateTime::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use DateTime::Format::Pg;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 BEGIN
12 2 ▶{
Subroutine BEGIN: called CC=3 SCAR=21.8
13 # Look ma, I can auto-generate all these :)
14 2 my @types = qw(datetime timestamp timestamptz time timetz date duration);
15 2 foreach my $type (@types) {
16 14 my @args = ($type) x 3;
17 14 ▶ push @args, $type eq 'duration' ? ", 'DateTime::Duration'" : '';
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'duration' ? : 2 12 14
18 0 ▶ eval sprintf(<<' EOM', @args);
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine __ANON__: not called CC=1 SCAR=6.8
Subroutine has_date: not called CC=3 SCAR=24.6
Subroutine has_datetime: not called CC=3 SCAR=24.6
Subroutine has_duration: not called CC=3 SCAR=24.6
Subroutine has_time: not called CC=3 SCAR=24.6
Subroutine has_timestamp: not called CC=3 SCAR=24.6
Subroutine has_timestamptz: not called CC=3 SCAR=24.6
Subroutine has_timetz: not called CC=3 SCAR=24.6
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
Branch: 7 branches
BranchTrueFalseTotal
exists $opts->{'constructor_args'} ? : 0 0 0
exists $opts->{'constructor_args'} ? : 0 0 0
exists $opts->{'constructor_args'} ? : 0 0 0
exists $opts->{'constructor_args'} ? : 0 0 0
exists $opts->{'constructor_args'} ? : 0 0 0
exists $opts->{'constructor_args'} ? : 0 0 0
exists $opts->{'constructor_args'} ? : 0 0 0
Condition0%0/14
shift() || {}
l!l
00
shift() || {}
l!l
00
shift() || {}
l!l
00
shift() || {}
l!l
00
shift() || {}
l!l
00
shift() || {}
l!l
00
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
MC/DC0%0/1
shift() || {}
shift()
MC/DC0%0/1
shift() || {}
shift()
MC/DC0%0/1
shift() || {}
shift()
MC/DC0%0/1
shift() || {}
shift()
MC/DC0%0/1
shift() || {}
shift()
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
19 sub has_%s
20 {
21 my $class = shift;
22 my $column = shift;
23 my $opts = shift || {};
24  
25 my @args = exists $opts->{constructor_args} ?
26 @{$opts->{constructor_args}} : ();
27  
28 my $fmt = DateTime::Format::Pg->new(@args);
29 my $inflate = sub { $fmt->parse_%s(shift) };
30 my $deflate = sub { $fmt->format_%s(shift) };
31 __PACKAGE__->_setup_column($class, $column, $inflate, $deflate%s);
32 }
33 EOM
34 }
35  
36 {
37 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 *has_interval = \&has_duration;
39  
40 2 my @methods = map { ("has_$_") } @types;
41 2 ▶ *_export_methods = sub { @methods };
Subroutine __ANON__: called CC=1 SCAR=0.0
42 }
43 }
44  
45 2 1;
46  
47 __END__
« DateTime/Base.pm ↑ Summary DateTime/MySQL.pm »