blib/lib/DBIx/Table/Dup.pm

filter: Statementstmt 52.7% 19 / 36 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 50.0% 1 / 2 totaltotal 46.1% 24 / 52 CC 5 SCAR 27.5
CC
5
Cov
43%
this
30.0
date_string
2.0
BEGIN
1.0
CRAP 15.6
↑ Summary
1 package DBIx::Table::Dup;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use DBIx::DBSchema;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 require Exporter;
10  
11 1 our @ISA = qw(Exporter);
12  
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
16  
17 # This allows declaration use DBIx::Table::Dup ':all';
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
19 # will save memory.
20 1 our %EXPORT_TAGS = ( 'all' => [ qw(
21
22 ) ] );
23  
24 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
25  
26 1 our @EXPORT = qw(
27
28 );
29 1 our $VERSION = '0.03';
30  
31  
32 # Preloaded methods go here.
33  
34 0 ▶sub date_string {
Subroutine date_string: not called CC=1 SCAR=6.9
Pod undocumented
35  
36 0 my $d = lc `date +%b_%d_%H_%M_%S`;
37 0 chomp $d;
38 0 $d;
39  
40 }
41  
42 0 ▶sub this {
Subroutine this: not called CC=5 SCAR=34.0
Pod documented
43  
44 0 my (undef, $dbh, $tbl_name, $dup_name, $create, $append) = @_;
45  
46 0 ▶ $tbl_name or die 'must supply table to dup';
Branch: 1 branch
BranchTrueFalseTotal
$tbl_name or die "must supply table to dup" 0 0 0
47  
48 0 ▶ $dup_name or die 'must supply table dup table name';
Branch: 1 branch
BranchTrueFalseTotal
$dup_name or die "must supply table dup table name" 0 0 0
49  
50 # warn $dbh;
51  
52 0 my $schema = new_native DBIx::DBSchema $dbh;
53  
54 # warn $schema;
55  
56 0 my @table_names = $schema->tables;
57  
58 # warn "@table_names";
59  
60 0 ▶ grep { $tbl_name eq $_ } @table_names or die
Branch: 1 branch
BranchTrueFalseTotal
grep {$tbl_name eq $_;} @table_names or die "$tbl_name not found in @table_names" 0 0 0
61 "$tbl_name not found in @table_names";
62  
63 0 my $table = $schema->table($tbl_name);
64  
65 # warn $table;
66  
67 0 my ($table_create) = $table->sql_create_table($dbh);
68  
69 0 $table_create =~ s!CREATE TABLE \w+!CREATE TABLE $dup_name!;
70  
71 0 $table_create .= $append;
72  
73 0 ▶ return $table_create unless $create;
Branch: 1 branch
BranchTrueFalseTotal
unless $create 0 0 0
74  
75 # warn $table_create;
76  
77 0 $dbh->do($table_create);
78  
79 0 return $table_create;
80  
81 }
82  
83 1 1;
84 __END__
↑ Summary